|
On May 8, 2009, at 10:31 AM, Michael Glotzer wrote:
> Could anyone enlighten me on how to interconvert region selections
> and (segmented) lines in ImageJ? Both regions and lines are defined
> by a series of points, but some measurements and other operations
> require a line and others require a region. Are they
> interconvertible at some level?
Area selections (except for composite selections) and line selections
are defined by a list of points. To convert from an area selection to
a line selection, get the list of points and use it to create a line
selection. To convert a line selection to an area selection, get the
list of points and use it to create an area selection. Here is a
macro that converts an area selection to line selection and a line
selection to an area selection:
type = selectionType;
getSelectionCoordinates(xCoordinates, yCoordinates);
if (type==0||type==2) {
// convert rectangle or polygon to polyline
makeSelection("polyline", xCoordinates, yCoordinates);
} else if (type==1||type==3||type==4) {
// convert ellipse, freehand or traced selection to freeline
makeSelection("freeline", xCoordinates, yCoordinates);
} else if (type==6) {
//convert segmented line to polygon
makeSelection("polygon", xCoordinates, yCoordinates);
} else if (type==7) {
// convert polyline to freehand outline
makeSelection("freehand", xCoordinates, yCoordinates);
} else
print("Unsupported type: "+type
-wayne
|