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

DM-42313: PixelFlags offimage check should flag non-finite positions #261

Merged
merged 5 commits into from Jan 3, 2024

Conversation

parejkoj
Copy link
Contributor

No description provided.

Copy link
Member

@kfindeisen kfindeisen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, some style and testing comments.

src/PixelFlags.cc Outdated Show resolved Hide resolved
if (!mimage.getBBox().contains(geom::Point2I(center))) {
// Flag centroids off the image.
geom::Box2D bbox(mimage.getBBox());
if (!bbox.contains(center)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment explaining why you're specifically converting int to float instead of the other way around?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to worry about the differing coordinate systems for Boxes (which does not come up when converting Points)? Put another way, if center has coordinates of (0,0), is it in the middle of the corner pixel, or at the image corner?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case that covers these off-image or borderline centroids?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I've added some tests of this.

As far as I can tell, the behavior I've implemented here doesn't change how points on the boundary are handled. For example, Point2I(Point2D(-20.55, 20.55)) gives Point2I(-21, 21) (the Point2I constructor rounds from Point2D), which in effect already "expands" the image bbox by 0.5 pixels, as the Box2D(Box2I) constructor describes.

src/PixelFlags.cc Outdated Show resolved Hide resolved
src/PixelFlags.cc Outdated Show resolved Hide resolved
src/PixelFlags.cc Outdated Show resolved Hide resolved
The code had set flag_edge if the source was off the chip, but the
docstring did not specify that.
There is no Box2I.contains(Point2D), so we have to cast the box instead
of the centroid, if we want it to work for non-finite values.
Catching NaN centroids early means that the offimage flag is not set
for them, but it should be.
Reformat exception message to be more useful (although the measurement
task squashes all these to debug level logs, so noone ever sees them
anyway).
Add tests of non-finite centroids and sources right on the image boundary.
@parejkoj parejkoj merged commit 025927a into main Jan 3, 2024
2 checks passed
@parejkoj parejkoj deleted the tickets/DM-42313 branch January 3, 2024 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants