Login  Register

why pixels are shown in strange values??

Posted by 周鑫 on Jan 26, 2014; 7:12am
URL: http://imagej.273.s1.nabble.com/why-pixels-are-shown-in-strange-values-tp5006280.html

Hi all,

I found some strange result when I program with ImageJ.
The version I use is still 1.46.

What happened is that I simply applied a crop operation in ImageProcessor.
Here is the code:

public static ImageStack getCroppedStack(ImageStack ip_stack, int x, int y, int crop_width, int crop_height)
    {
        ImageStack stack     = ip_stack;
        int    size             = stack.getSize();
       
        ImageStack cropped_stack = new ImageStack(crop_width, crop_height);
       
        for (int i=1; i<=size; i++)
        {
            ImageProcessor iproc = stack.getProcessor(i);
            iproc.setRoi(x,y,crop_width, crop_height);
            ImageProcessor croppedIp = iproc.crop();
            cropped_stack.addSlice(croppedIp);
        }
       
        return cropped_stack;
    }

The strange problem I had is that the value on each pixels in new stack is represented in a strange way.
For example, in ImageJ, when I looked at the two stack with the mouse pointed to one pixel, the original stack shows:
x=137.80, y= 72.48, z=0, value = 46
But in cropped stack, it shows
x=37.80, y= 22.48, z=0, value = -32722.00 (46)
why the correct value is in () but a negative value is used instead??

Yes, I forgot to say that imagej.plugins.nifti_io.Nifti_Writer is used to save the cropped stack in niifti format.
Anyone has an idea of what happened??

It is important because many operation refuse the negative values and I had a series of errors generated.

Best regards, Xin




--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html