Hi,
I discovered that when tracing an horizontal line on an image and retrieving
the profile intensity, the number of points is artificially increased by one
when setting a line width larger than one.
Here is a python script that reproduces the issue
from ij import IJ
from ij.gui import Line
imp = IJ.openImage("http://imagej.net/images/Cell_Colony.jpg")
imp.show()
h = imp.getHeight()
w = imp.getWidth()
for line_thickness in (1, 5):
roi = Line(0,int(h/2),w,int(h/2))
roi.setLineWidth(line_thickness)
imp.setRoi(roi)
y = roi.getPixels()
print("Line thickness: %d - Number of points on the X axis:
%d"%(line_thickness,len(y)))
This inconsistency only happens when the line is perfectly horizontal. I looked
at the code and it seems that the extra point at the end of the profile is
generated by the function PolygonRoi.fitSplineForStraightening() called by
Straightener.straightenLine().
In my tests I could see this happening only when the Line Roi is horizontal,
and it affects also a profile plot (e.g. when calling IJ.run(imp, "Plot
Profile", "")).
In my script I was able to bypass the issue by using instead a rectangular Roi
with height equal to the line thickness, but I thought it was important to be
aware of this anomaly.
Best,
Giovanni
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html