Posted by
vischer on
Oct 12, 2013; 8:51pm
URL: http://imagej.273.s1.nabble.com/Strange-results-after-Fit-Spline-tp5005151.html
Hello All,
The "Fit Spline" algorithm gives strange results for segmented lines consisting of long and short segments. The macro below is an extreme example: Four points are arranged as straight horizontal line, thus one would expect that fitting a straight line would not change anything.
However, the fitting procedure extends the line with U-turns: the measured length jumps from 201 to 300.3 pix, and the profile (which automatically employs fitting) includes two peaks that are not on the line.
Meanwhile I found out that I can avoid the problem by uncommenting the line containing "Interpolate". But possibly ImageJ could avoid such unexpected behaviour in the first place.
By the way, the problem above also occurs if an end-point is recorded twice (replace 101 by 100 in the demo).
Norbert
close("spline-test");
newImage("spline-test", "8-bit ramp", 500, 500, 1);
makeRectangle(80, 50, 4, 100);
changeValues(0, 255, 255);
xx = newArray(100, 101, 300, 301);
yy = newArray(90, 90, 90, 90);
makeSelection("polyline", xx, yy);
waitForUser;
run("Set Measurements...", "perimeter");
run("Clear Results");
run("Measure");
//run("Interpolate", "interval=0.1");
run("Measure");
run("Fit Spline");
run("Measure");
run("Plot Profile");
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html