Login  Register

Create an Tiff image reading pixel values of 16 bit signed image

Posted by Muqeet Khan on Nov 20, 2009; 2:24pm
URL: http://imagej.273.s1.nabble.com/Create-an-Tiff-image-reading-pixel-values-of-16-bit-signed-image-tp3690357.html

I have a 16-bit signed image, i want to create a tiff image by reading the pixel values of the 16-bit signed image. For some reason i don't get a proper tiff image when doing it. Here are the steps.

ImagePlus createImage(ImagePlus imagePlus, ImageProcessor targetImage) {
   
    int pixelCount = imagePlus.getWidth() * imagePlus.getHeight();
    Short pixels[] = new Short[pixelCount]
    ImageProcessor iP = imagePlus.getProcessor();
    int count = 0;    

    for (int x = 0;x < imagePlus.getWidth(); x++) {
       
        for (int y = 0; y < imagePlus.getHeight; y++) {
            double pixelValue = iP.getPixelValue(x, y);
            pixels[count] = pixelValue;
            count ++;
        }
    }
   
    targetImage.setPixels(pixels);
    targetImage .resetMinAndMax();
    return new ImagePlus("Image-RXZ", targetImage);
}

Is this correct way of doing???