Overlay Scalebar Plugins

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

Overlay Scalebar Plugins

Lim Soon Yew
Dear All,

I would like to add an overlay scalebar to a fluorescent image as a length reference. Is there a plugin similar to "ScaleBar Plus" that can be used to add an overlay scale bar to an image? I need the scale bar to be an overlay as the image will be used for farther processing.

Any suggestions would be appreciated.

Thank you and best regards,
John Lim
Reply | Threaded
Open this post in threaded view
|

Re: Overlay Scalebar Plugins

Divakar Ramachandran-2
On Thursday 19 May 2011 07:32 AM, Lim Soon Yew wrote:
> Dear All,
>
> I would like to add an overlay scalebar to a fluorescent image as a length reference. Is there a plugin similar to "ScaleBar Plus" that can be used to add an overlay scale bar to an image? I need the scale bar to be an overlay as the image will be used for farther processing.
>
> Any suggestions would be appreciated.
>
> Thank you and best regards,
> John Lim
A couple of thoughts on this: Yes, it would be useful. I usually have
around three versions of each image - a raw image as obtained from a
microscope, a TIFF version after applying calibration information and a
JPG version with the scale bar burned in. If it were possible to have
the scale bar in the overlay I could store a single version in TIFF
format (other formats would not store the overlay separately). But ...
the overlay is monochrome (?), and would it print well? and give me the
option of viewing / processing with / without the scale bar?

Divakar
Reply | Threaded
Open this post in threaded view
|

Re: Overlay Scalebar Plugins

Frank Sprenger
In reply to this post by Lim Soon Yew
Dear John,

I took a scalebar macro that Wayne at some point created and hacked around it a bit to create a scalebar overlay macro tool

I am sure that this kind of macro is not written very well, but for me it works. Give it a try

Best

Frank



pixelH = getHeight();
pixelW = getWidth();
getPixelSize(scale, pixelSize, x);
Dialog.create("Scale Bar Parameters");
Dialog.addNumber("Length in current units:", 10);
choice1 = newArray("black", "white", "red", "green", "blue", "yellow", "magenta", "cyan");
Dialog.addChoice("Color:", choice1);
choice2 = newArray("Top Left", "Top Right", "Bottom Left", "Bottom Right");
Dialog.addChoice("Position:", choice2);
Dialog.addCheckbox("Black Box", false);
Dialog.addCheckbox("Hide text", false);

Dialog.show();

inLength = Dialog.getNumber();
inColor = Dialog.getChoice();
inPos = Dialog.getChoice();

if (Dialog.getCheckbox()==true){
        bb=1;
        }else
        bb=0;
       
if (Dialog.getCheckbox()==true){
        ht=1;
        }else
        ht=0;

sbLength = inLength / pixelSize;
sbHeight = pixelH / 100;

if (inColor == "white"){
        setColor(255,255,255);
}else if (inColor == "black"){
setColor(0,0,0);
}else if (inColor == "red"){
setColor(255,0,0);
}else if (inColor == "green"){
setColor(0,255,0);
}else if (inColor == "blue"){
setColor(0,0,255);
}else if (inColor == "yellow"){
setColor(255,255,0);
}else if (inColor == "magenta"){
setColor(255,0,255);
}else if (inColor == "cyan"){
setColor(0,255,255);
}

 
if (inPos == "Top Left") {
        sbXcoord = pixelW / 30;
        sbYcoord = pixelH / 30;
} else if (inPos == "Top Right") {
        sbXcoord = pixelW - sbLength - (pixelW / 30);
        sbYcoord = pixelH / 30;
} else if (inPos == "Bottom Left") {
        sbXcoord = pixelW / 30;
        sbYcoord = pixelH - sbHeight - (pixelH / 30);
} else if (inPos == "Bottom Right") {
        sbXcoord = pixelW - sbLength - (pixelW / 30);
        sbYcoord = pixelH - sbHeight - (pixelH / 30);
}

if (bb==1)
{
inColor2="black";
sbreclenght = (sbLength + (sbLength*0.2));
if (sbreclenght < 50)
{
x = 50;
sbreclenght = x;
}else;
if (ht==1)
{
sbrecheight = (2.5*sbHeight);
sbrecYcoor = (sbYcoord-(0.75*sbHeight));
}else;
if (ht==0)
{
sbrecheight = (5*sbHeight);
sbrecYcoor = (sbYcoord-(3*sbHeight));
}else;
sbrecXcoor = (sbXcoord-(sbreclenght*0.1));
makeRectangle(sbrecXcoor, sbrecYcoor, sbreclenght,sbrecheight);
run("Add Selection...", "stroke=" + inColor + " width=1 fill=" + inColor2);
}else;

makeRectangle(sbXcoord, sbYcoord, sbLength, sbHeight);
run("Add Selection...", "stroke=" + inColor + " width=1 fill=" + inColor);

if (ht==0)
{
textSize = pixelH / 50;
textYcoord = sbYcoord - (pixelH / 200);
label = toString(inLength) + " " + scale;

setFont("SansSerif", textSize);
Overlay.drawString(label, sbXcoord, textYcoord);
Overlay.add;
Overlay.show;
}
Reply | Threaded
Open this post in threaded view
|

Re: Overlay Scalebar Plugins

Lim Soon Yew
Dear Frank,

Thank you for the overlay scalebar macro. It works nicely.

Best Regards,
John Lim
________________________________________
From: ImageJ Interest Group [[hidden email]] On Behalf Of Frank Sprenger [[hidden email]]
Sent: Monday, May 23, 2011 11:41 PM
To: [hidden email]
Subject: Re: Overlay Scalebar Plugins

Dear John,

I took a scalebar macro that Wayne at some point created and hacked around it a bit to create a scalebar overlay macro tool

I am sure that this kind of macro is not written very well, but for me it works. Give it a try

Best

Frank



pixelH = getHeight();
pixelW = getWidth();
getPixelSize(scale, pixelSize, x);
Dialog.create("Scale Bar Parameters");
Dialog.addNumber("Length in current units:", 10);
choice1 = newArray("black", "white", "red", "green", "blue", "yellow", "magenta", "cyan");
Dialog.addChoice("Color:", choice1);
choice2 = newArray("Top Left", "Top Right", "Bottom Left", "Bottom Right");
Dialog.addChoice("Position:", choice2);
Dialog.addCheckbox("Black Box", false);
Dialog.addCheckbox("Hide text", false);

Dialog.show();

inLength = Dialog.getNumber();
inColor = Dialog.getChoice();
inPos = Dialog.getChoice();

if (Dialog.getCheckbox()==true){
        bb=1;
        }else
        bb=0;

if (Dialog.getCheckbox()==true){
        ht=1;
        }else
        ht=0;

sbLength = inLength / pixelSize;
sbHeight = pixelH / 100;

if (inColor == "white"){
        setColor(255,255,255);
}else if (inColor == "black"){
setColor(0,0,0);
}else if (inColor == "red"){
setColor(255,0,0);
}else if (inColor == "green"){
setColor(0,255,0);
}else if (inColor == "blue"){
setColor(0,0,255);
}else if (inColor == "yellow"){
setColor(255,255,0);
}else if (inColor == "magenta"){
setColor(255,0,255);
}else if (inColor == "cyan"){
setColor(0,255,255);
}


if (inPos == "Top Left") {
        sbXcoord = pixelW / 30;
        sbYcoord = pixelH / 30;
} else if (inPos == "Top Right") {
        sbXcoord = pixelW - sbLength - (pixelW / 30);
        sbYcoord = pixelH / 30;
} else if (inPos == "Bottom Left") {
        sbXcoord = pixelW / 30;
        sbYcoord = pixelH - sbHeight - (pixelH / 30);
} else if (inPos == "Bottom Right") {
        sbXcoord = pixelW - sbLength - (pixelW / 30);
        sbYcoord = pixelH - sbHeight - (pixelH / 30);
}

if (bb==1)
{
inColor2="black";
sbreclenght = (sbLength + (sbLength*0.2));
if (sbreclenght < 50)
{
x = 50;
sbreclenght = x;
}else;
if (ht==1)
{
sbrecheight = (2.5*sbHeight);
sbrecYcoor = (sbYcoord-(0.75*sbHeight));
}else;
if (ht==0)
{
sbrecheight = (5*sbHeight);
sbrecYcoor = (sbYcoord-(3*sbHeight));
}else;
sbrecXcoor = (sbXcoord-(sbreclenght*0.1));
makeRectangle(sbrecXcoor, sbrecYcoor, sbreclenght,sbrecheight);
run("Add Selection...", "stroke=" + inColor + " width=1 fill=" + inColor2);
}else;

makeRectangle(sbXcoord, sbYcoord, sbLength, sbHeight);
run("Add Selection...", "stroke=" + inColor + " width=1 fill=" + inColor);

if (ht==0)
{
textSize = pixelH / 50;
textYcoord = sbYcoord - (pixelH / 200);
label = toString(inLength) + " " + scale;

setFont("SansSerif", textSize);
Overlay.drawString(label, sbXcoord, textYcoord);
Overlay.add;
Overlay.show;
}
Reply | Threaded
Open this post in threaded view
|

Re: Overlay Scalebar Plugins

Krs5
For those who are interested. I have taken the code from Frank and made changes and added choice of font size, scale bar height, option to choose any position for scale bar and some options that allow to set the image calibration (only for overlay, not in Meta data). You can find it at: http://www.le.ac.uk/biochem/microscopy/macros.html

Kees

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Lim Soon Yew
Sent: 25 May 2011 03:28
To: [hidden email]
Subject: Re: Overlay Scalebar Plugins

Dear Frank,

Thank you for the overlay scalebar macro. It works nicely.

Best Regards,
John Lim
________________________________________
From: ImageJ Interest Group [[hidden email]] On Behalf Of Frank Sprenger [[hidden email]]
Sent: Monday, May 23, 2011 11:41 PM
To: [hidden email]
Subject: Re: Overlay Scalebar Plugins

Dear John,

I took a scalebar macro that Wayne at some point created and hacked around it a bit to create a scalebar overlay macro tool

I am sure that this kind of macro is not written very well, but for me it works. Give it a try

Best

Frank



pixelH = getHeight();
pixelW = getWidth();
getPixelSize(scale, pixelSize, x);
Dialog.create("Scale Bar Parameters");
Dialog.addNumber("Length in current units:", 10);
choice1 = newArray("black", "white", "red", "green", "blue", "yellow", "magenta", "cyan");
Dialog.addChoice("Color:", choice1);
choice2 = newArray("Top Left", "Top Right", "Bottom Left", "Bottom Right");
Dialog.addChoice("Position:", choice2);
Dialog.addCheckbox("Black Box", false);
Dialog.addCheckbox("Hide text", false);

Dialog.show();

inLength = Dialog.getNumber();
inColor = Dialog.getChoice();
inPos = Dialog.getChoice();

if (Dialog.getCheckbox()==true){
        bb=1;
        }else
        bb=0;

if (Dialog.getCheckbox()==true){
        ht=1;
        }else
        ht=0;

sbLength = inLength / pixelSize;
sbHeight = pixelH / 100;

if (inColor == "white"){
        setColor(255,255,255);
}else if (inColor == "black"){
setColor(0,0,0);
}else if (inColor == "red"){
setColor(255,0,0);
}else if (inColor == "green"){
setColor(0,255,0);
}else if (inColor == "blue"){
setColor(0,0,255);
}else if (inColor == "yellow"){
setColor(255,255,0);
}else if (inColor == "magenta"){
setColor(255,0,255);
}else if (inColor == "cyan"){
setColor(0,255,255);
}


if (inPos == "Top Left") {
        sbXcoord = pixelW / 30;
        sbYcoord = pixelH / 30;
} else if (inPos == "Top Right") {
        sbXcoord = pixelW - sbLength - (pixelW / 30);
        sbYcoord = pixelH / 30;
} else if (inPos == "Bottom Left") {
        sbXcoord = pixelW / 30;
        sbYcoord = pixelH - sbHeight - (pixelH / 30);
} else if (inPos == "Bottom Right") {
        sbXcoord = pixelW - sbLength - (pixelW / 30);
        sbYcoord = pixelH - sbHeight - (pixelH / 30);
}

if (bb==1)
{
inColor2="black";
sbreclenght = (sbLength + (sbLength*0.2));
if (sbreclenght < 50)
{
x = 50;
sbreclenght = x;
}else;
if (ht==1)
{
sbrecheight = (2.5*sbHeight);
sbrecYcoor = (sbYcoord-(0.75*sbHeight));
}else;
if (ht==0)
{
sbrecheight = (5*sbHeight);
sbrecYcoor = (sbYcoord-(3*sbHeight));
}else;
sbrecXcoor = (sbXcoord-(sbreclenght*0.1));
makeRectangle(sbrecXcoor, sbrecYcoor, sbreclenght,sbrecheight);
run("Add Selection...", "stroke=" + inColor + " width=1 fill=" + inColor2);
}else;

makeRectangle(sbXcoord, sbYcoord, sbLength, sbHeight);
run("Add Selection...", "stroke=" + inColor + " width=1 fill=" + inColor);

if (ht==0)
{
textSize = pixelH / 50;
textYcoord = sbYcoord - (pixelH / 200);
label = toString(inLength) + " " + scale;

setFont("SansSerif", textSize);
Overlay.drawString(label, sbXcoord, textYcoord);
Overlay.add;
Overlay.show;
}