Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Jan 13, 2013; 3:15am
URL: http://imagej.273.s1.nabble.com/ROI-defined-by-two-parallel-lines-tp5001382p5001386.html
On Jan 11, 2013, at 11:05 PM, Oleg Broytman wrote:
> Greetings. I study airway wall remodeling and fibrosis in a rat model of
> asthma. My typical image is a transverse section of the rat lung, where I
> can see a portion of the airway wall (not the full circle around the
> airway, but just a sector of that circle). To quantify the staining, I
> would like to make an ROI of the airway wall by drawing two parallel
> freehand lines, outlining the inside and outside border of the wall, and
> defining the ROI as the area between those lines on 2 sides, and the top
> and bottom of the image as the other 2 sides.
>
> I have 2 questions:
> - When I draw the first freehand line, and click the cursor somewhere else
> to draw the second line, the first line disappears. How can I avoid this?
>
> - Once I have the two lines drawn, how do I define an ROI bound by lines
> that don't connect to one another?
You can do this sort of thing using a macro set like the one attached. To use it, create a line selection, press "1", create a parallel line selection, press "2", and the two line selections will be converted into an area selection. It requires the ImageJ 1.47i daily build, which adds the Overlay.addSelection() and Overlay.activateSelection() macro functions. To upgrade, use the Help>Update ImageJ command and select "daily build" from the drop down menu. Information about the ImageJ macro language is available at
http://imagej.nih.gov/ij/developer/macro/macros.html-wayne
macro "Save First Line [1]" {
if (!isLine())
exit("No line selection");
Overlay.remove;
Overlay.addSelection;
}
macro "Create ROI [2]" {
if (!(isLine() && Overlay.size==1))
exit("No line selection and no line overlay");
getSelectionCoordinates(x1, y1);
Array.reverse(x1);
Array.reverse(y1);
Overlay.activateSelection(0);
getSelectionCoordinates(x2, y2);
x = Array.concat(x1,x2);
y = Array.concat(y1,y2);
makeSelection("freehand", x, y);
Overlay.remove;
}
function isLine() {
return (selectionType>=5 && selectionType<=7);
}
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html