I met a problem when I try to decide the color of the objects with my algorithm,it is done like that:
There are two objects in the scene,one object is covered with texture,which is grayscale image of 8-bits, and the range of the pixel value is between 0 and 255. The other object’s color will be decided by my algorithm.
The value of each pixel is calculated, which are between 0 and x(value is unknown ),they are all float number, as you know, the float number must be transform into unsigned char type to form an image. So the minimum value and maximum value must be found out. And I use the
formula (x-min)/(max-min)*255 to get the range I need.
The problem is that the pixel value of the first object needn’t transformation, but the second needs transformation. However the two objects’ pixel value are in the same output buffer, I can’t figure out which values come from the first object, and which are from the second object. That is to say, I can’t find out the minimum and maximum pixel value of the second object, and I also can’t know which data should be transformed and which needn’t.
So is there anyone who can solve my problem? Thank you very much!