I’m working on a machine vision project and there is a need to increase the contrast of the image. Was wondering if any of guys would know how to do this in Blender using nodes that way I can turn it over to C code. The images will be in greyscale.
Well, it’s easy enough in Blender-use the Brightness/Contrast Node. turning that into C code though…??eh??
If the image is greyscale, I think you can make one scan through the pixels, calculating mean, defference, min and max. Calculate a transform function to make max 256 and min 0 and values inbetween to fall inside a standard distribution.
lol I spose you oculd use the contrast node, but say you didn’t have that contrast node and you wanted to get that same effect, how would you do it?
use the RGB Curves node as I explained here: http://wiki.blender.org/index.php/Manual/Compositing_Nodes_Color#RGB_Curves_Node
Ok, in answer to your next question, if i didnt have that and wanted to do it mathematically, if I knew the image was centered around medium gray (127), use the map value node with an offset of -.5, a factor of 2, fed to another map value node with an offset of .5 with max and min at 1 and 0.see http://wiki.blender.org/index.php/Manual/Compositing_Nodes_Vector#Map_Value_Node
And if you ask again, I am forced to use the ColorRamp node by sliding the white and black values toward the middle. see http://wiki.blender.org/index.php/Manual/Compositing_Nodes_Convertors#ColorRamp_Node
And if you ask again, i will let someone else answer.
If you mean you need the C code to increase the contrast of an image, the algorithm I used in one of my old plugins was:
that would be for an image with a float buffer…if you are dealing with a char image buffer I believe you just replace the .5 with 128…below are some samples of what it does.
if cont==1 the image is unchanged:…and if cont==0, the image is a uniform grey:
thanks for the replies guys but I ended up just converting the RGB to HSV and that seems to be working pretty good.