run("Enlarge...", "enlarge=-1"); when touching edge of field

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

run("Enlarge...", "enlarge=-1"); when touching edge of field

Michael Cammer
I have found that using the run("Clear Outside"); command in a macro
sometimes leaves a few pixels at the edge of the selection.

Therefore, I want to shrink the region of interest by one pixel before
clearing.  So I tried run("Enlarge...", "enlarge=-1");

The problem is that there is always at least one part of the ROI touching
the edge of the image, so the error "Cannot shrink selections touching
image edge" is returned.

Would it be possible to change ImageJ so that if run("Enlarge...",
"enlarge=-1"); is given a negative number, it will work?  I may be able to
solve the problem in the meantime by using analyze particles, but would
prefer to do it this way:

     run("Enlarge...", "enlarge=-1");
     run("Clear Outside");
     doWand(0, getHeight()/2);

Thank you.

using ImageJ 1.39e  Java 1.5.0_09 on Windows Vista
_________________________________________
Michael Cammer   http://www.aecom.yu.edu/aif/
Reply | Threaded
Open this post in threaded view
|

Re: run("Enlarge...", "enlarge=-1"); when touching edge of field

Gabriel Landini
On Sunday 23 September 2007 20:13:13 Michael Cammer wrote:
> I have found that using the run("Clear Outside"); command in a macro
> sometimes leaves a few pixels at the edge of the selection.
>
> Therefore, I want to shrink the region of interest by one pixel before
> clearing.  So I tried run("Enlarge...", "enlarge=-1");
>
> The problem is that there is always at least one part of the ROI touching
> the edge of the image, so the error "Cannot shrink selections touching
> image edge" is returned.

What about i this:

enlarge your canvas by 1 pixels in all directions (i.e. 2 pixels larger,
centred),
restore the ROI (because it will get deleted when resizing)
shrink your ROI
reduce your canvas by 1 pixel in all directions
restore ROI.

In a macro, asuming you have a 256x256 image with a ROI touching the border:

run("Canvas Size...", "width=258 height=258 position=Center zero");
run("Restore Selection");
run("Enlarge...", "enlarge=-1");
run("Canvas Size...", "width=256 height=256 position=Center zero");
run("Restore Selection");

I hope it helps,

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: run("Enlarge...", "enlarge=-1"); when touching edge of field

Wayne Rasband
In reply to this post by Michael Cammer
On Sep 23, 2007, at 3:13 PM, Michael Cammer wrote:

> I have found that using the run("Clear Outside"); command in a macro
> sometimes leaves a few pixels at the edge of the selection.

Send a small test macro that reproduces this problem and I will try to
find a fix.

> Therefore, I want to shrink the region of interest by one pixel before
> clearing.  So I tried run("Enlarge...", "enlarge=-1");
>
> The problem is that there is always at least one part of the ROI
> touching
> the edge of the image, so the error "Cannot shrink selections touching
> image edge" is returned.
>
> Would it be possible to change ImageJ so that if run("Enlarge...",
> "enlarge=-1"); is given a negative number, it will work?

It will work in ImageJ 1.39f.

-wayne

>   I may be able to
> solve the problem in the meantime by using analyze particles, but would
> prefer to do it this way:
>
>      run("Enlarge...", "enlarge=-1");
>      run("Clear Outside");
>      doWand(0, getHeight()/2);
>
> Thank you.
>
> using ImageJ 1.39e  Java 1.5.0_09 on Windows Vista
> _________________________________________
> Michael Cammer   http://www.aecom.yu.edu/aif/
>