Login  Register

Re: Add border to image

Posted by Tycho Scholtens on Jan 17, 2006; 6:58pm
URL: http://imagej.273.s1.nabble.com/Add-border-to-image-tp3704047p3704051.html

Curtis,

Thanks for the help but it's not exactly what I mean.
Later I realized that I failed to mention that the border should be added to
the image, instead of changing some pixels to black at the border.
So: Say my image is 1000x1000 pixels and I want a 10 pixel border. Then I
would like the image to be 1020x1020 pixels, while ImageJ still "thinks" its
1000x1000 pixels as to not affect particle measurements.
I just thought there would be an internal function for this like there is in
Labview image processing.

Thanks,

Tycho

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Curtis
Rueden
Sent: dinsdag 17 januari 2006 18:25
To: [hidden email]
Subject: Re: Add border to image

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