Add border to image

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

Add border to image

Tycho Scholtens
Hi all,

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?

 

Thanks in advance,

 

-----------------------------------------------------
Ir. Tycho Scholtens
Biophysical Engineering
Faculty of Science and Technology
University of Twente
P.O. Box 217
7500 AE Enschede
The Netherlands
Tel.: +31 (0) 53 489 2004
 
<http://by18fd.bay18.hotmail.msn.com/cgi-bin/compose?curmbox=F000000001&a=9c
73dd4dd02727df3cbc1ae5ce6f66a0c1278c3e949b7730438420053193ec8f&mailto=1&to=t
.[hidden email]&msg=MSG1134382365.1&start=20682793&len=2184&src=&type=
x> [hidden email]
 <javascript:ol('http://www.tnw.utwente.nl/bpe/');>
http://www.tnw.utwente.nl/bpe/

 
Reply | Threaded
Open this post in threaded view
|

Re: Add border to image

ctrueden
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
Reply | Threaded
Open this post in threaded view
|

Re: Add border to image

Tycho Scholtens
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
Reply | Threaded
Open this post in threaded view
|

Re: Add border to image

Gabriel Landini
In reply to this post by ctrueden
> >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.

Enlarge the canvas by the desired amount and then set an ROI of the original
image size so the ROI covers only the original part of the image and leaves
the borders unprocessed.
The Particle analyzer will operate only on the ROI.
Is that what you need?

Cheers,
Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Add border to image

Tycho Scholtens
I thinks this will work.
Thanks.

Tycho

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Gabriel Landini
Sent: Tuesday, January 17, 2006 10:43 PM
To: [hidden email]
Subject: Re: Add border to image

> >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.

Enlarge the canvas by the desired amount and then set an ROI of the original

image size so the ROI covers only the original part of the image and leaves
the borders unprocessed.
The Particle analyzer will operate only on the ROI.
Is that what you need?

Cheers,
Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Add border to image

ajaytechie07
Hi,
  Could you please tell me how to make this border transparent.
Reply | Threaded
Open this post in threaded view
|

Re: Add border to image

Michael Schmid
Hi Tycho,

for a transparent border, you could try something like this

b = 3; //border width
w = getWidth();
h = getHeight();
makeRectangle(b, b, w-2*b, h-2*b);
run("Make Inverse");
run("Multiply...", "value=0.5");
run("Select None");

To change the brightness of the border you can also add some number after 'Multiply', see Process>Math>Add. Assuming it's an 8-bit or RGB image, suitable numbers are between 1 and 128.

Use the Command Recorder (Plugins>Macros>Record) to determine the macro command for adding.

Michael
________________________________________________________________
On Dec 10, 2015, at 21:34, ajaytechie07 wrote:

> Hi,
>  Could you please tell me how to make this border transparent.

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