Posted by
Michael Schmid on
May 20, 2010; 2:02pm
URL: http://imagej.273.s1.nabble.com/How-to-correct-32bits-RGB-images-tp3688233p3688234.html
On 20 May 2010, at 15:22, NatashaW wrote:
> 1) When I convert them to float (rgbip.convertToFloat) I got very
> bright
> images.. I don’t know if my images were damaged during the
> converting and if I can still work on them and get information from
> the
> pixels values?
> 2) When I worked only with byte (without converting to float) I get my
> images in the same contrast so can I apply this method or I’m going
> to lose
> many details during division?
Hi Natasha,
ImageProcessor.convertToFloat does not damage anything; the reason
for the different way it is displayed is autoscaling of Float images:
if the data are, say, 1-120, 1 is displayed as black and 120 as
white. For 8-bit images, by default, you have a display range of
0-255, irrespective of the image data.
When you convert back to RGB, you should recover a reasonable
brightness range unless you have 'scale conversions' true (this would
take the full range of the float data for the 0-255 range of each 8-
bit color channel).
If you do more than one operation, you will have better precision
when using float data, especially if you have some intermediate step
where the data range becomes less than that of the original data.
For most cases, I would recommend the ImageProcessor.toFloat(int
channelNumber, FloatProcessor fp) and setPixels(int channelNumber,
FloatProcessor fp) methods - these do not any scaling and allow you
to write a plugin that works on all types of images (gray and RGB):
//input: ip1 and ip2
//output: ip1
FloatProcessor fp1 = null, fp2 = null;
for (int i=0; i<ip.getNChannels(); i++) {
fp1 = ip1.toFloat(i, fp1);
fp2 = ip2.toFloat(i, fp2);
do_Some_Float_Operation(fp1, fp2);
ip1.setPixels(i, fp1);
}
Michael