ImageJ icon indicating copy to clipboard operation
ImageJ copied to clipboard

Problem with rasterization of line and point ROIs

Open imagingbook opened this issue 9 years ago • 1 comments

When I used the point iterator on line and point ROIs I found that the obtained point coordinates are often wrong. In particular,

  • the terminal points of lines are not rendered correctly,
  • some consecutive line points have duplicates with identical positions,
  • coordinates of points in single and multi-point ROIs are generally off by one pixel.

Test images (containing selected ROIs) can be found here (tried to attach a ZIP file but it was rejected).

In this course I also looked at the behavious of Line.getPixels() and found similar deficiencies. The end point of the line was never included and the resulting array of pixel values also contained duplicates from the same locations (which I believe is not intended). However, even when interpolation is ON, the getPixels() method missed the last point on the line.

The mapping from float or double to int coordinates is apparently flawed in several places. I suggest to use this version to calculate the right offset (which will also work for negative coordinates):

double x, y;  // original position
int u = (int) Math.round(x - 0.5);
int v = (int) Math.round(y - 0.5);

Perhaps this should be packed into a single conversion method. There may be related problems in other places.

I have worked out a patch which can be found in this repo. Will send a pull request shortly. Hope this is useful, pls. let me know if anything's unclear.

--Wilhelm

PS: The announced pull request is here.

imagingbook avatar Apr 22 '17 15:04 imagingbook

Posted a new pull request: https://github.com/imagej/imagej1/pull/34

imagingbook avatar May 03 '17 15:05 imagingbook