I have 2 rois which perfectly abut each other. I need to know the length of the line of abutment. The picture i have drawn here is something like what i mean although the lines here are not perfectly aligned unlike in reality
Is this possible? Thanks ![]() |
On Thursday 10 May 2012 12:04:50 flettster wrote:
> I have 2 rois which perfectly abut each other. I need to know the length of > the line of abutment. The picture i have drawn here is something like what i > mean although the lines here are not perfectly aligned unlike in reality Way better and easier than operating with ROIs I would to operate on the objects that those ROIs define: Fill (binary) the Rois in separate images, dilate once one of them, compute "AND" and then measure the result. Cheers Gabriel |
Many thanks for a rapid response.
How do i dilate? and this would give me length of the abutted line? Thanks Andy |
In reply to this post by flettster
If the lines overlap you should be able to use run("Interpolate", "interval=1") (if any lines are straight) followed by getSelectionCoordinates(xCoordinates, yCoordinates) http://rsbweb.nih.gov/ij/developer/macro/functions.html#G for each and then march through the arrays to find the beginning and ending intersecting points. However, now ImageJ may return decimal pixel locations so you may have to check how to deal with these.
-Michael C. -----Original Message----- From: * [mailto:[hidden email]] On Behalf Of flettster Sent: Thursday, May 10, 2012 7:05 AM To: [hidden email] Subject: Roi I have 2 rois which perfectly abut each other. I need to know the length of the line of abutment. The picture i have drawn here is something like what i mean although the lines here are not perfectly aligned unlike in reality Is this possible? Thanks http://imagej.1557.n6.nabble.com/file/n4965400/untitled.jpg -- View this message in context: http://imagej.1557.n6.nabble.com/Roi-tp4965400.html Sent from the ImageJ mailing list archive at Nabble.com. |
The lines are not straight unfortunately! Any other ideas? I can elaborate if the objective is in doubt?
Its odd, i tried using the "xor" and the "and" functions and was able to generate 2 shapes which when the measured perimeters were subtracted ought to have been the length. But the perimeter must refer to something other than the perimeter because it clearly was not the length of said line! Thanks andy |
In reply to this post by Cammer, Michael
If interested in pursuing the getCoordinates method, I ran a little test and posted the results at
http://www.flickr.com/photos/mcammer/7171545460/ Regards, Michael C. -----Original Message----- From: * [mailto:[hidden email]] On Behalf Of Cammer, Michael Sent: Thursday, May 10, 2012 9:08 AM To: [hidden email] Subject: Re: Roi If the lines overlap you should be able to use run("Interpolate", "interval=1") (if any lines are straight) followed by getSelectionCoordinates(xCoordinates, yCoordinates) http://rsbweb.nih.gov/ij/developer/macro/functions.html#G for each and then march through the arrays to find the beginning and ending intersecting points. However, now ImageJ may return decimal pixel locations so you may have to check how to deal with these. -Michael C. -----Original Message----- From: * [mailto:[hidden email]] On Behalf Of flettster Sent: Thursday, May 10, 2012 7:05 AM To: [hidden email] Subject: Roi I have 2 rois which perfectly abut each other. I need to know the length of the line of abutment. The picture i have drawn here is something like what i mean although the lines here are not perfectly aligned unlike in reality Is this possible? Thanks http://imagej.1557.n6.nabble.com/file/n4965400/untitled.jpg -- View this message in context: http://imagej.1557.n6.nabble.com/Roi-tp4965400.html Sent from the ImageJ mailing list archive at Nabble.com. |
Im not sure if that will work or not. I have uploaded an image and a roi set. I need the length of the line shared by "Endo" and "man".
download Thanks for all the options so far. Andy |
Dear Andy
flettster <drflett@...> writes: > Im not sure if that will work or not. I have uploaded an image and a roi set. > I need the length of the line shared by "Endo" and "man". > http://dl.dropbox.com/u/1070657/test%20%282%29.zip Gabriel's suggestion is your best bet. For that, you would create 2 masks (one for each ROI) using 'Edit>Selection> Create Mask', run 'Process>Binary>Dilate' on one of the masks, and then 'Process>Image Calculator...' to compute AND between the two masks. You can, however, perform logical operations on ROIs using the ROI Manager. The following macro applied to your dataset exemplifies it: // ------- requires("1.45i"); roiManager("select", 0); // select Endo run("Enlarge...", "enlarge=1"); setSelectionName("DilatedEndo"); roiManager("add"); roiManager("select", newArray(2,3)); // select man and enlarged Endo roiManager("AND"); run("Set Measurements...", "perimeter"); run("Measure"); lenght = getResult("Perim.", nResults-1)/2; showMessage("Abut Region", "Length (perim./2): "+ lenght); // ------- HTH, -tiago |
I tried the mask technique. When i create the first mask, it creates a new image. When i create the second, it overlays it on the first! so i cant make an "AND" function since there is only one image? once i have the new mask (if i can get it to work), do i just measure and take the area of the line as a length or the (perimeter -2)/2? I also tried the ROI macro method. It nicely produced a single pixel roi of the overlap. Problem is, when i measure it, the perimeter is 175. the area is 42. BUT when i draw a freehand line, it is length 54! i dont get it! which is the real length of the line? Dear Andy flettster <drflett@...> writes: > Im not sure if that will work or not. I have uploaded an image and a roi set. > I need the length of the line shared by "Endo" and "man". > http://dl.dropbox.com/u/1070657/test%20%282%29.zip Gabriel's suggestion is your best bet. For that, you would create 2 masks (one for each ROI) using 'Edit>Selection> Create Mask', run 'Process>Binary>Dilate' on one of the masks, and then 'Process>Image Calculator...' to compute AND between the two masks. You can, however, perform logical operations on ROIs using the ROI Manager. The following macro applied to your dataset exemplifies it: // ------- requires("1.45i"); roiManager("select", 0); // select Endo run("Enlarge...", "enlarge=1"); setSelectionName("DilatedEndo"); roiManager("add"); roiManager("select", newArray(2,3)); // select man and enlarged Endo roiManager("AND"); run("Set Measurements...", "perimeter"); run("Measure"); lenght = getResult("Perim.", nResults-1)/2; showMessage("Abut Region", "Length (perim./2): "+ lenght); // ------- HTH, -tiago |
Anyone any resolution to this problem?
Thanks Andy |
Hi,
On May 17, 2012, at 2:04 AM, flettster wrote: > Anyone any resolution to this problem? > I assume that you are referencing the perimeter length difference? (It's hard to tell because you haven't quoted any part of the post you were responding to.) Assuming that you are asking about perimeter calculation, you might find it helpful to read this nice FAQ found on the ImageJ DocuWiki http://imagejdocu.tudor.lu/doku.php?id=faq:technical:what_are_the_algorithms_used_to_calculate_particle_area_and_perimeter Cheers, Ben > Thanks > > Andy > > -- > View this message in context: http://imagej.1557.n6.nabble.com/Roi-tp4965400p4991343.html > Sent from the ImageJ mailing list archive at Nabble.com. |
Free forum by Nabble | Edit this page |