Re: Freehand selections
Posted by
Blandine Chanteloup on
Aug 23, 2005; 8:11am
URL: http://imagej.273.s1.nabble.com/Freehand-selections-tp3704990p3704993.html
Here is the code of FreehandRoiBis :
import ij.*;
import ij.gui.*;
public class FreehandRoiBis extends FreehandRoi {
public FreehandRoiBis(int x, int y, ImagePlus imp) {
super(x, y, imp);
}
public void grow(int ox, int oy) {
super.grow(ox, oy);
}
}
Hope that will help you &;)
>Would you mind sharing the code of FreehandRoiBis? I'm still having
>difficulties ...
>(e.g. for roi.drawPixels(myImageProcessor); I'm getting a compiler error
>(drawPixels() in ij.gui.Roi cannot be applied to
>(ij.process.ImageProcessor)). Thanks a lot!
>
>
>>
>>Finally,
>>
>>I've defined a FreehandRoiBis classe inherited from the FreehandRoi one
>>where the grow() method is public and not protected.
>>And here is my code:
>>
>>import java.awt.*;
>>import java.awt.event.*;
>>import javax.swing.*;
>>
>>public class JFrame_TestImageJROI extends javax.swing.JFrame
>> implements MouseListener, MouseMotionListener {
>> private ij.IJ myImageJ;
>> private ij.ImagePlus myImagePlus;
>> private ij.process.ImageProcessor myImageProcessor;
>> private ij.gui.ImageCanvas myImageCanvas;
>>
>> private FreehandRoiBis roi;
>>
>> int xOrigROI;
>> int yOrigROI;
>>
>> public static void main(String[] args) {
>> JFrame_TestImageJROI inst = new JFrame_TestImageJROI();
>> inst.setVisible(true);
>> }
>>
>> public JFrame_TestImageJROI() {
>> super();
>> initGUI();
>> }
>>
>> private void initGUI() {
>> try {
>>
>>setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
>> this.setFocusable(false);
>> pack();
>> setSize(400, 300);
>> myImageJ = new ij.IJ();
>> myImageJ.open("image.bmp");
>> myImagePlus = myImageJ.getImage();
>> myImageProcessor = myImagePlus.getProcessor();
>> myImageProcessor.setColor(Color.yellow);
>> myImageProcessor.setLineWidth(2);
>>
>> myImageCanvas = new ij.gui.ImageCanvas(myImagePlus);
>> this.add(myImageCanvas);
>>
>> myImageCanvas.addMouseListener(this);
>> myImageCanvas.addMouseMotionListener(this);
>>
>> } catch (Exception e) {
>> e.printStackTrace();
>> }
>> }
>> public void mousePressed(MouseEvent evt) {
>> xOrigROI = evt.getX();
>> yOrigROI = evt.getY();
>> roi = new FreehandRoiBis(evt.getX(), evt.getY(),
>> myImagePlus);
>> myImagePlus.setRoi(roi);
>> roi.drawPixels(myImageProcessor);
>> myImagePlus.setProcessor(null,myImageProcessor);
>> myImageCanvas.repaint();
>> }
>> public void mouseDragged(MouseEvent evt) {
>> roi.grow(evt.getX(), evt.getY());
>> roi.drawPixels(myImageProcessor);
>> myImagePlus.setProcessor(null,myImageProcessor);
>> myImageCanvas.repaint();
>> }
>> public void mouseReleased(MouseEvent evt) {
>> roi.grow(xOrigROI,yOrigROI);
>> roi.drawPixels(myImageProcessor);
>> myImagePlus.setProcessor(null,myImageProcessor);
>> myImageCanvas.repaint();
>> }
>> public void mouseClicked(MouseEvent evt) {}
>> public void mouseExited(MouseEvent evt) {}
>> public void mouseEntered(MouseEvent evt) {}
>> public void mouseMoved(MouseEvent evt) {}
>>}
>>
>>Thanks everybody and especially Volker
>>
>>
>>>Hello,
>>>
>>>Does anybody know the name of the macro or plugin or function called
>>>when the mouse is pressed on the "Freehand selection" button in the
>>>ImageJ toolbar ???
>>>
>>>Please HELP ....
>>>
>>>Thanks
>>>
>>>Blandine