Extracting the pixel data contained in an Roi

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

Extracting the pixel data contained in an Roi

Robert Lockwood
I'm trying to extract pixel or image data from an Roi with the intent of
displaying it elsewhere but magnified.  I can create an Roi that follows
the mouse pointer in my JImagePanel.  This code displays a 21x21 Roi
centered on the cursor/mouse/toolTip and displays just as planned.

// overlay and roi creation
    private Overlay overlay = new Overlay();
    private int  roiHalfHeight = 10;
    private int roiHalfWidth = 10;
    private Roi toolTipRoi = new Roi(0, 0, 2*roiHalfWidth + 1,
2*roiHalfHeight + 1);

// when an new TIFF image is read
// ejip is  JImagePanel
      ejip.autoContrast(imp);
      overlay.add(toolTipRoi);
      ejip.imp.setOverlay(overlay);

//  the mouse motion adaptor for the JImagePanel
        ejip.addMouseMotionListener(new MouseMotionAdapter() {
            @Override
            public void mouseMoved(MouseEvent e) {
                int xPos = (int) (e.getX());
                int yPos = (int) (e.getY());

                toolTipRoi.setLocation((double) (xPos - roiHalfWidth - 1),
(double)(yPos - roiHalfHeight - 1));
                ejip.imp.draw();
                ejip.repaint();
            }
        });

How do I capture the image in the Roi so that I may display it magnifiled?
This line displays a sequence of copies of the original image which is not
what I want:

new ImagePlus("selected region", ejip.imp.getProcessor().crop()).show();

Thanks, Nate
--
When I was 12 I thought I would live forever.
So far, so good.

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