Login  Register

Re: restricting drawing to an ROI

Posted by Joe Edwards on May 12, 2016; 12:36am
URL: http://imagej.273.s1.nabble.com/restricting-drawing-to-an-ROI-tp5016377p5016415.html

I could find no straight forward (to me) way to use
existing ImageJ methods to keep the drawing inside our figures.

So I added a few lines to the ImageProcessor & ByteProcessor.
Now I can move on. Thanks for your advice.

in my plugin:
  ip.setShapeRoi(sr);

diff ImageProcessor.java
104,111d103
< protected ShapeRoi shapeRoi;
<
< public void setShapeRoi(ShapeRoi shapeRoi) {
<     this.shapeRoi=shapeRoi;
< }
< public ShapeRoi getShapeRoi() {
<     return shapeRoi;
< }

diff -bBtw ByteProcessor.java
343d342
< if(shapeRoi==null || shapeRoi.contains(x, y)) {
351d349
< }
358d355
< if(shapeRoi==null || shapeRoi.contains(x, y)) {
364d360
< }
369d364
< if(shapeRoi==null || shapeRoi.contains(x, y))

Joe Edwards
UWMC, ITS, Senior Computer Specialist


On Mon, 9 May 2016, Joe Edwards wrote:

>
> I reviewed lots of plugins and read over several tutorials.
> Including, 'Image Processing with ImageJ' and the ImageJ twiki.
> And I've searched the forum.
>
> I have a plugin that defines an ROI and draws to the image.
> It is based on plugins that others have shared.
>
> public int setup(String arg, ImagePlus imp) {
> ...
> ...
> imp = IJ.getImage();
> vwt = new Versatile_Wand_Tool();
> vwt.doWand(imp, 172, 172, 0, 0, 0, "");
> sr0 = new ShapeRoi(imp.getRoi());
> imp.killRoi();
> vwt.doWand(imp, 516, 172, 0, 0, 0, "");
> sr1 = new ShapeRoi(imp.getRoi());
> sr = sr0.or(sr1);
> s = sr.getShape();
> imp.setRoi(sr);
> ...
> ...
> }
>
> The img has the ROI set.
> But, I do not understand how to limit the drawing to the ROI.
> I'd like a hint or, better, an example.
> I do not see how to get a Shape to the Graphics2.setClip() method
> to restrict drawing.

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