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

Patch: Problem with rasterization of line and point ROIs (issue #30) #31

Closed
wants to merge 15 commits into from
Closed

Conversation

imagingbook
Copy link

This is a proposed patch for issue #30.

WilhelmBurger added 15 commits April 22, 2017 15:01
…tPolygon subdivision. It uses the same algorithm as the ImageProcessor.getLine(double, double, double, double) method for calculating integer-position line points but was fixed to properly include endpoints and to eliminate duplicate points.
…backed default point iterator. The iterator() method is overridden in subclass 'Line', which returns a specific point iterator for thin lines but falls back on the mask-backed default iterator for thick lines.
…rator of 'Line' for the case that 'interpolate" == false. If 'interpolate' is true, interpolated pixel values are extracted at regularly-spaced continuous positions between the two line endpoints (by the new method getLineInterpolated()). This method uses the original algorithm but was fixed to properly include the line's endpoints.
@rasband
Copy link
Member

rasband commented Apr 24, 2017

These fixes are in the latest ImageJ daily build (1.51m28).

@rasband rasband closed this Apr 24, 2017
@rasband
Copy link
Member

rasband commented Apr 30, 2017

The modified ImageProcess.getLine() method is not in the released version of ImageJ 1.51m. It does not behave the same way as the original version, potentially causing compatibility problems.

@imagingbook
Copy link
Author

I understand, compatibility is important. Though I guess it is the very idea of a bug fix to change behavior...

@rasband
Copy link
Member

rasband commented May 1, 2017

The modified version of getLine() did not always behave as expected. For example, it returned a 3 element array for lines 1.1 pixels long. Here is some JavaScript code that demonstrates this behavior:

ip = new ByteProcessor(100,100);
ip.setInterpolate(true);
values = ip.getLine(100.0,100.0,100.0,101.1);
print("values.length: " + values.length);

@imagingbook
Copy link
Author

I will look into this problem asap. A possible deeper problem is that there are two different interpretations of floating-point coordinates in ImageJ:

  1. ROI coordinates: The image pixel (u, v) is interpreted to extend over the rectangle x in [u, u+1) and y in [v, v+1). Thus, the exact center of the image pixel at integer grid position (0,0) has the ROI position (0.5, 0.5). By rounding, all ROI coordinates in the range [u-0.5, u+0.5) are mapped to the grid position u.

  2. Sample coordinates: In contrast, when calling ip.getLine(x1, y1, x2, y2), the floating point coordinates mean positions in the sampling plane. In this case, the point (0.0, 0.0) is exactly ON the sample position (0,0).

Thus there is a systematic offset of (0.5, 0.5) between these two coordinate systems, and I am not sure if currently this is properly addressed. Assuming that related operations should share a common semantics, the question is where to correct for this offset. I suppose it should happen consistently in the ROI context and coordinates should refer to the sample raster everywhere else. Any better options?

--Wilhelm

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

Successfully merging this pull request may close these issues.

None yet

2 participants