问题描述
我想量化蝴蝶翅膀上一条线的形状,它可以从非常直到类似于景观中的地平线,或类似于图表(每个 x 值只有 1 y 值) ),尽管总体方向各不相同。我的想法是使用徒手工具来追踪感兴趣的线,然后让 ImageJ 宏对其进行量化(自动化这可能很棘手,因为有许多线状结构)。两个特质对我来说似乎很有用;
其他特征,例如在连接极端的直线下方或下方的线的比例也可能有用。 这怎么编码?我正在构建一个交互式宏,提示测量开放图像的各种特征。 希望以下(非功能性)代码能够传达我正在尝试做的事情。
//line shape analysis
run("Select None");
setTool("free hand");
waitForUser("Trace the line between point A and B");
length= measure();
String command = "Directionality";
new PlugInFilterRunner(da,command,"nbins=60,start=-90,method=gradient");
get data...
//to get distance between points A and B
run("Select None");
setTool("multipoint");
waitForUser("distances","Click on points A and B \nAfter they appear,you can click and drag them if you need to readjust.");
getSelectionCoordinates(xCoordinates,yCoordinates);
xcoordsp = xCoordinates;
ycoordsp = yCoordinates;
makeLine(xcoordsp[0],ycoordsp[0],xcoordsp[1],ycoordsp[1]);
List.setMeasurements;
StrLength = List.getValue("Length");
我曾在网上寻找解决方案,但对这个相对简单的问题却发现很少。
亲切的问候, 弗里克
解决方法
这里有一个简单的解决方案,用于确定直线与品脱 A 和 B 之间的直线偏离的程度。“直线度”是两个度量之间的比例。
// To meausure line length to compare to length of straight line aka Euclidean distance
run("Select None");
setTool("polyline");
waitForUser("Trace the line between point V5 and V3 by clickinmg at each corner finish by double click"); // Points V5 and V3 refer to point A and B It can be adjusted
run("Measure");
getStatistics(Perim);
FLR=Perim; // FLR For forewing lenght real
// to get Euclidian distance between points A and B
run("Select None");
setTool("multipoint");
waitForUser("Distances","Click on points A and B \nAfter they appear,you can click and drag them if you need to readjust.");
getSelectionCoordinates(xCoordinates,yCoordinates);
xcoordsp = xCoordinates;
ycoordsp = yCoordinates;
makeLine(xcoordsp[0],ycoordsp[0],xcoordsp[1],ycoordsp[1]);
List.setMeasurements;
FLS = List.getValue("Length"); // FLS For forewing length straight
}
如果有更复杂的线路参数,我将不胜感激