Centering a ROI on a light spot

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

Centering a ROI on a light spot

CARL Philippe (LBP)
Dear all,
Let's say I have a circular ROI which is placed (but not precisely) on top on a light spot.
Is there an efficent / easy method to center this ROI on the spot?
I thank you very much on your lightings on this.
My best regards,
Philippe

Philippe CARL
Laboratoire de Bioimagerie et Pathologies
UMR 7021 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 42 89

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Centering a ROI on a light spot

Cammer, Michael-3
Would you like it centered on the intensity peak or on the centroid based on the perimeter of the spot?

Either way, yes.

Regards-
Michael Cammer

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of CARL Philippe (LBP)
Sent: Wednesday, September 30, 2020 9:36 AM
To: [hidden email]
Subject: Centering a ROI on a light spot

[EXTERNAL]

Dear all,
Let's say I have a circular ROI which is placed (but not precisely) on top on a light spot.
Is there an efficent / easy method to center this ROI on the spot?
I thank you very much on your lightings on this.
My best regards,
Philippe

Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 42 89

--
ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=DwIFaQ&c=j5oPpO0eBH1iio48DtsedeElZfc04rx3ExJHeIIZuCs&r=hUBj2D5n6oKThx2L01qn8IORZb5f-ruLVXPmQ1zQNnM&m=UMOWSoLIXxZ0WKP7NsOLHsaPDJYcaX13jwXzXb87OqA&s=EtdfVwwUnfbPLnsG26GzIHfh3FuJxy2WNVMF2cDAloE&e=

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Centering a ROI on a light spot

CARL Philippe (LBP)
Dear Michael,
Rather on the perimeter of the spot or if you prefer the "whole spot".
Because the most intense pixel may not be in the center.
My best regards,
Philippe

----- Mail original -----
De: "Cammer, Michael"
À: "imagej"
Envoyé: Mercredi 30 Septembre 2020 15:54:35
Objet: Re: Centering a ROI on a light spot

Would you like it centered on the intensity peak or on the centroid based on the perimeter of the spot?

Either way, yes.

Regards-
Michael Cammer

-----Original Message-----
From: ImageJ Interest Group On Behalf Of CARL Philippe (LBP)
Sent: Wednesday, September 30, 2020 9:36 AM

Subject: Centering a ROI on a light spot

[EXTERNAL]

Dear all,
Let's say I have a circular ROI which is placed (but not precisely) on top on a light spot.
Is there an efficent / easy method to center this ROI on the spot?
I thank you very much on your lightings on this.
My best regards,
Philippe

Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 42 89

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Centering a ROI on a light spot

Stein Rørvik
In reply to this post by CARL Philippe (LBP)
What I usually do is to centre the ROI based on the centre of mass. I just calculate the offset between the mass centre and the geometrical centroid, and shift the ROI by this amount.

The advantage with this method is that you get a "weighted" centering, not dependent on any max value that may lie in a random place. See this macro for an example:

newImage("Untitled", "8-bit black", 500, 500, 1);
makeOval(156, 169, 22, 22);
run("Fill", "slice"); //draw a white spot
makeOval(117, 127, 135, 135); //make an off-centre ROI

waitForUser("Please continue to auto-center ROI based on mass centre");

centroidX = getValue("X raw");
centroidY = getValue("Y raw");

centreOfMassX = getValue("XM raw");
centreOfMassY = getValue("YM raw");

print("Centroid: ", centroidX, centroidY);
print("Centre of Mass: ", centreOfMassX, centreOfMassY);

offsetX = centreOfMassX - centroidX;
offsetY = centreOfMassY - centroidY;
print("Offset: ", offsetX, offsetY);

Roi.getBounds(x, y, width, height)
Roi.move(x + offsetX, y + offsetY);'


The disadvantage with the above macro is that it requires the entire object of interest to be inside the ROI. That is, the edges of the ROI should be near zero. An example where this macro does NOT work well is the Galaxy example image:

run("M51 Galaxy (16-bits)");
makeOval(138, 234, 58, 60);
//repeat above macro from here

Here the macro is NOT able to centre the ROI on the centre of the galaxy as you wanted, as there are too many "background" stars which also contribute to the centre of mass. The macro works however if you repeat it a few times, iterating the ROI upon the mass centre.

Stein

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of CARL Philippe (LBP)
Sent: 30. september 2020 15:36
To: [hidden email]
Subject: Centering a ROI on a light spot

Dear all,
Let's say I have a circular ROI which is placed (but not precisely) on top on a light spot.
Is there an efficent / easy method to center this ROI on the spot?
I thank you very much on your lightings on this.
My best regards,
Philippe

Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 42 89

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7Cdb9fdc40aa284c8aa16408d86546a57c%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637370701403031839&amp;sdata=jevzl8uSkRmqIjo5uKt55uebjoL1FbYd7wf0V6wDsGw%3D&amp;reserved=0

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