Posted by
Michael Schmid on
May 10, 2016; 1:22pm
URL: http://imagej.273.s1.nabble.com/Strange-results-with-latest-API-and-line-selections-tp5016381p5016385.html
Hi anonymous,
yes, there are small, subtle differences for different ways of measuring
along a line:
'Measure' uses the points along a line as given by 'Plot Profile'.
The spacing of these pints is close to 1, but not exactly 1, to make
sure that the first and last point are exactly the corresponding points
of the line.
The new iterator gives you points with a spacing of exactly 1 pixel.
In general, the last point will not be exactly the end point of the line.
Both use sub-pixel coordinates. For 'Measure' and line profiles, you can
set in Edit>Options>Plot whether to interpolate between the pixels to
get the pixel values.
In practice, I think that these differences don't really matter, because
the finite resolution of an image with pixels will cause sampling errors
in any case.
Michael
________________________________________________________________
On 2016-05-10 12:32, Bio7 wrote:
> I'm using the latest ImageJ API to transfer and edit ROI selections. All
> other selections work fine so far.
>
> However if I use the line selection I get different results when calculating
> the mean if I invoke the action "Measure" or when I use the new API to get
> the contained pixel values with: Roi.getContainedPoints().
>
> Here an example:
>
> imp = IJ.openImage("
http://wsr.imagej.net/images/blobs.gif");
> imp.show();
> imp.setRoi(new Line(87,99,120,115));
> IJ.run(imp, "Measure", "");
>
> The mean in the measurements dialog is: 140.632
>
> if I calculate now the mean from the pixel values in the ROI I get a
> different result:
>
> count=0;
> sum=0;
> img = IJ.getImage();
> ip=img.getProcessor();
> roi = img.getRoi();
> iter = roi.iterator();
> while (iter.hasNext()) {
> p = iter.next();
> sum+=ip.getPixelValue(p.x, p.y);
> count=count+1
> }
> print(sum/count);
>
> The mean is: 142.054
>
> If I use an ImageJ macro instead oddly I get floating point results:
>
> p=Roi.getContainedPoints(x,y);
>
> for (i=0; i<x.length; i++){
> print(getPixel(x[i],y[i]));
> }
>
> Do I miss something or is this a bug for the line selection?
>
> All other selections seems to give the correct (equal) results.
>
>
>
>
> --
> View this message in context:
http://imagej.1557.x6.nabble.com/Strange-results-with-latest-API-and-line-selections-tp5016381.html> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html