logo       

Re: RGB to 32 Bit Gray: msg#00115

java.imagej

Subject: Re: RGB to 32 Bit Gray

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



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise