Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with rasterization of line and point ROIs #30

Open
imagingbook opened this issue Apr 22, 2017 · 1 comment
Open

Problem with rasterization of line and point ROIs #30

imagingbook opened this issue Apr 22, 2017 · 1 comment

Comments

@imagingbook
Copy link

imagingbook commented Apr 22, 2017

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
Copy link
Author

Posted a new pull request: #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant