Using ImageJ to display images in a JPanel

J

jfalter

I am using ImageJ to display DICOM files in part of a JPanel using an
ImageCanvas. I want to be able to scroll through the frames of the
file using a scroll bar or a field to jump to the proper frame. I have
been unable to get the ImageCanvas to refresh though. The only way
that I have been able to get it to work is by removing the old
ImageCanvas, and inserting a new one with the new image, which produces
a predictably horrid amount of flickering. I have read through the
implementation of ImageWindow, but have not been able to determine what
they are doing differently. Any help with this would be appreciated.
Here is the relevant parts of the code:

private ij.IJ myImageJ;
private ij.ImagePlus myImagePlus;
private ij.gui.ImageCanvas myImageCanvas;
private JPanel pnlControls;

myImageJ = new ij.IJ();
myImageJ.open("uc.dcm");
myImagePlus = myImageJ.getImage();
myImageCanvas = new ij.gui.ImageCanvas(myImagePlus);
pnlControls = new JPanel();

pnlControls.add(myImageCanvas);

Then which ever listener catches an event calls a method, which gets
the new Frame index. So the problem is then getting that new frame
into the ImageCanvas and displaying it.
Anyone have experience with this?
 
J

jfalt

Well, I finally solved this problem, so I figured I'd post the solution
for the next poor chap who runs into it.

Simply put, my code for updating the ImageCanvas was working:

public void setFrameNumber(int number)
{
myImagePlus.setSlice(number);
myImageCanvas.setImageUpdated();
myImageCanvas.repaint();
}

The problem was that ImageJ has some problems with Java 1.4. I
switched to JDK 1.5 and it was fixed.

In the future, anyone using ImageJ should always use 1.5 to avoid
problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top