Re: RGB to 32 Bit Gray
Posted by Wayne Rasband on Nov 15, 2005; 2:46pm
URL: http://imagej.273.s1.nabble.com/RGB-to-32-Bit-Gray-tp3704468p3704469.html
> I tried your Macro (IJ 1.35g, Windows XP). It worked however the
> resulting 32 bit gray image turned out to be inverted,a matter of byte
> order??
The newImage() function was creating an image with an inverting lookup
table. Adding 'black' (fill with black) to the second argument fixes
the problem. Here is the updated macro.
if (bitDepth!=24)
exit("RGB image required");
setBatchMode(true);
w = getWidth;
h = getHeight;
rgb = getImageID;
newImage("32-bit", "32-bit black", w, h, 1);
float = getImageID;
for (y=0; y<h; y++) {
showProgress(y, h);
for (x=0; x<w; x++) {
selectImage(rgb);
v = getPixel(x,y)&0xffffff;
selectImage(float);
setPixel(x, y, v);
}
}
resetMinAndMax;
setBatchMode(false);
//run("16-bit");
-wayne