Login  Register

problem with showing 16bit greyscale image

Posted by Peter Nagy-2 on May 12, 2007; 10:36am
URL: http://imagej.273.s1.nabble.com/problem-with-showing-16bit-greyscale-image-tp3699477.html

Dear list members,
The plugin below extracts a column from an image stack. It works fine
for 8-bit grey scale images (when replacing the short variables with
byte), but for 16-bit images the result is strange. The image data is
there in the output image, because when I place the mouse over the
image, the pixel values are displayed. But there are two problems:
1. when I check the max value of the image with getMax(), I get zero.
2. the image LUT is such that everything is white.


And a 3rd question, when I close the newly created image window, I'm
not asked if I would like to save it.

Can anyone tell me where the problem is?

Thanks,
Peter



public void run(ImageProcessor oldproc) {

short [] newpixels0,pixels0;
ImageProcessor ip;
int w=oldproc.getWidth();
int h=oldproc.getHeight();
int z=oldimplus.getStackSize();
ImageStack oldstack=oldimplus.getStack();
ImageStack s=new ImageStack(100,100);
ImageProcessor temp_ip=oldproc.createProcessor(100,100);
pixels0=new short[w*h];
for (int i=1;i<=z;i++) {
newpixels0=new short[100*100];
pixels0=(short []) oldstack.getPixels(i);
for (int y=100;y<200;y++) {
int offset1_image=y*w;
int offset1_roi=(y-100)*100;
for (int x=100;x<200; x++) {
newpixels0[offset1_roi+x-100]=pixels0[offset1_image+x];
}
}
s.addSlice(null,newpixels0);
}
ImagePlus e;
e=new ImagePlus("extracted",s);
e.show();
ImageProcessor e_ip;
e_ip=e.getProcessor();
IJ.write(Double.toString(oldproc.getMax()));
IJ.write(Double.toString(e_ip.getMax()));

}