image gets fully white if i set window level

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

image gets fully white if i set window level

Prashant-2-3
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
Reply | Threaded
Open this post in threaded view
|

Re: image gets fully white if i set window level

Michael Schmid
Hi,

to me it looks like a problem with the
  public void paint(Graphics g)
method of your viewer. Probably it does not paint the image (g.drawImage)
except on the first call, so any repaint operation will leave it white.
E.g., do you have the bufferedImage in a class variable, so that it
remains accessible in a separate (repaint) thread)?

Michael
______________________________________________________________________


On Mon, August 10, 2009 12:35, prashant wrote:

> 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.
>
>
>
> Thanks in advance
>
> Prashant
>
Reply | Threaded
Open this post in threaded view
|

Re: image gets fully white if i set window level

Prashant-2-3
Thanks Michael,

On my paintComponent function I am doing like this...
Here

Image img;
ImagePlus implus;

Public void paintComponent(Graphicd g)
{
        if (implus == null)
        {
                return;
        }
        img = null;
       
        //getting current image from imageplus
        img = implus.getImage();

        if (img != null)
        {
                g.drawImage(img, drawx, drawy, drawx1, drawy1, null);
        }
}

After any change in window level I call below method.


implus.updateImage();
repaint();

thanks



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Michael Schmid
Sent: Monday, August 10, 2009 8:38 PM
To: [hidden email]
Subject: Re: image gets fully white if i set window level

Hi,

to me it looks like a problem with the
  public void paint(Graphics g)
method of your viewer. Probably it does not paint the image (g.drawImage)
except on the first call, so any repaint operation will leave it white.
E.g., do you have the bufferedImage in a class variable, so that it
remains accessible in a separate (repaint) thread)?

Michael
______________________________________________________________________


On Mon, August 10, 2009 12:35, prashant wrote:

> 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.
>
>
>
> Thanks in advance
>
> Prashant
>
Reply | Threaded
Open this post in threaded view
|

Re: image gets fully white if i set window level

Michael Schmid
Hi,

no obvious problem that I see, but a minor one that might cause
intermittent problems at most:
paintComponent should be multithread-safe. Thus, img should be a local
variable in that method.
This does not solve your problem, however (but I am not familiar with
Swing, so I would not expect to find it).
I would suggest adding statements like
  IJ.log("paintComponent, img="+img);
for debugging. Output will go into the log window; place it at some
position where it si not hidden by your viewer so you can see what
happens.

Michael

On Tue, August 11, 2009 07:47, prashant wrote:

> Thanks Michael,
>
> On my paintComponent function I am doing like this...
> Here
>
> Image img;
> ImagePlus implus;
>
> Public void paintComponent(Graphicd g)
> {
> if (implus == null)
> {
> return;
> }
> img = null;
>
> //getting current image from imageplus
> img = implus.getImage();
>
> if (img != null)
> {
> g.drawImage(img, drawx, drawy, drawx1, drawy1, null);
> }
> }
>
> After any change in window level I call below method.
>
>
> implus.updateImage();
> repaint();
>
> thanks
>
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Michael Schmid
> Sent: Monday, August 10, 2009 8:38 PM
> To: [hidden email]
> Subject: Re: image gets fully white if i set window level
>
> Hi,
>
> to me it looks like a problem with the
>   public void paint(Graphics g)
> method of your viewer. Probably it does not paint the image (g.drawImage)
> except on the first call, so any repaint operation will leave it white.
> E.g., do you have the bufferedImage in a class variable, so that it
> remains accessible in a separate (repaint) thread)?
>
> Michael
> ______________________________________________________________________
>
>
> On Mon, August 10, 2009 12:35, prashant wrote:
>> 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.
>>
>>
>>
>> Thanks in advance
>>
>> Prashant
>>
>