Login  Register

Re: Add border to image

Posted by ctrueden on Jan 17, 2006; 5:24pm
URL: http://imagej.273.s1.nabble.com/Add-border-to-image-tp3704047p3704048.html

Hi Tycho,

>I want to add a border to an image for event selection operations.
>
>I cannot seem to find a function in ImageJ that does this.
>
>Increasing the canvas size is 1 solution, however, this influences the
>results of particle analysis and that's not what I want.
>
>So, does any1 know a different way of doing this?
>  
>

Here is a macro that replaces the outermost pixel rows and columns
around the image with a solid border, by first cropping it, then
extending the canvas size back to the original width.

w = getWidth();
h = getHeight();
makeRectangle(1, 1, w-2, h-2);
run("Crop");
run("Canvas Size...", "width="+w+" height="+h+" position=Center");

I created the macro by recording the operations with the macro recorder
and then generalizing the width and height.

-Curtis