image gets fully white if i set window level
Posted by Prashant-2-3 on Aug 10, 2009; 10:35am
URL: http://imagej.273.s1.nabble.com/image-gets-fully-white-if-i-set-window-level-tp3691515.html
Hi Everyone,
I am creating a Dicom Image viewer.
I am using Imagej for opening uncompressed images and Loci for Compressed
images.
I am opening my compressed images with the help of bio-Formats.jar.
After that I convert this image to Imagej's ImagePlus object and then
displaying onto my panel.
Everything is successful but after display when I change a Window level or
window center with just a fraction
then image gets fully white.
Is there is any problem in conversion or why image is ok with window level
and window center.
Here is my code for conversion of compressed image to imagej
public ImagePlus openImage(String directory, String name)
{
stack = null;
try
{
////setting file name as id
String id = directory + name;
red = new ImageReader();
red.setId(id);
////for reading the metadata of image
mdr = new MetaDataReader(red);
////for reading the width and height of image
width = (short)red.getSizeX();
height = (short)red.getSizeY();
short imageCount = (short)red.getImageCount();
stack = new ImageStack(width, height);
BufferedImage bimg = null;
for (short i = 0; i < 1; i++)
{
bimg = red.openImage(i);
////creating a imageplus object with bimg
ImagePlus imp = new ImagePlus("", bimg);
////for getting image processor from imageplus object
ImageProcessor ip = imp.getProcessor();
stack.addSlice("", ip, i);
}
red.close(true);
}
catch (Exception e)
{
return null;
}
////create a new image plus object with above stack
//and return a new image Plus object
return new ImagePlus(name, stack);
}
Thanks in advance
Prashant