8000 Use center of pixel to determine if a pixel is in the ellipse mask by KRLango · Pull Request #67 · nion-software/niondata · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use center of pixel to determine if a pixel is in the ellipse mask #67

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

Merged
merged 3 commits into from
Jun 18, 2025

Conversation

KRLango
Copy link
Contributor
@KRLango KRLango commented Jun 12, 2025

Part of nion-software/nionswift#1472 - specifically the ellipse and rectangle mask. The centre of the shape has been shifted by 0.5 pixels towards the top right to ensure that the centre of the pixel is the position used to determine if it is in or out of the mask.

This is tested by the graphics tests in nionswift. Those tests have been updated in nion-software/nionswift#1548

The tests for both of these are now added here and nion-software/nionswift#1548 will be updated to use the new functions.

@KRLango KRLango requested review from Tiomat85 and lisham2000 June 12, 2025 14:09
@KRLango KRLango added the sprint issue is part of an active sprint label Jun 12, 2025
@cmeyer
Copy link
Collaborator
cmeyer commented Jun 12, 2025

Would it be possible to move all masking pixel functions and tests that are currently in nionswift to niondata? That way we update the two algorithms/tests separately from nionswift? Then the update sequence can go like this:

  • Add function_make_rectangle_mask to Core.py, which already contains function_make_elliptical_mask
  • Add tests to niondata to pixel test those two functions (these can be copied from nionswift)
  • Once this PR is finished, remove the duplicated tests from nionswift and change nionswift to use the new function_make_rectangle_mask in niondata.

As a general comment, I try to move all processing to niondata. Eventually we may want to move the Mask-like objects there, e.g. Graphics.SpotMaskItem. But for now, function_make_rectangle_mask needs to go there.

One other note: function_make_elliptical_mask is named differently. Should we name new function function_make_rectangle_mask or function_make_rectangular_mask?

Copy link
Collaborator
@cmeyer cmeyer left a comment

Choose a reason for hiding this comment

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

See comment above.

@KRLango KRLango force-pushed the 1472 branch 2 times, most recently from 6fd51ff to d572cad Compare June 13, 2025 09:55
@KRLango
Copy link
Contributor Author
KRLango commented Jun 13, 2025

@cmeyer Is there a reason that function_make_elliptical_mask is taking in tuples (albeit in an alias form) rather than Geometry.FloatPoint/Geometry.FloatSize? As far as I can tell all usages of it are currently turning the Geometry classes into tuples just to pass them in. Currently function_make_rectangular_mask uses the Geometry classes since that felt the most natural class to use, but I happy to change it if we want to.

@cmeyer
Copy link
Collaborator
cmeyer commented Jun 13, 2025

Is there a reason that function_make_elliptical_mask is taking in tuples (albeit in an alias form) rather than Geometry.FloatPoint/Geometry.FloatSize?

There were backwards compatibility issues in external code and in tests in other functions and I probably just carried that typing through to the new functions. There is a certain convenience when editing script functions where passing fn((20,40)) is easier than from nion.utils import Geometry; fn(Geometry.FloatPoint(20,40)), but I could easily be convinced to switch to the more strict typing in both cases - although that will require changes in both niondata and nionswift simultaneously, so it might be better to do this as a separate PR.

@cmeyer
Copy link
Collaborator
cmeyer commented Jun 13, 2025

tl/dr: new function can have strict Geometry.FloatXYZ typing.

@cmeyer
Copy link
Collaborator
cmeyer commented Jun 13, 2025

I didn't review the new PR yet, but I came across this separately:

Unfortunately, I didn't add tests in 942c69a4547a4900eeefc74e9bc55e2f9d396e14 but I think we should add them now, i.e. tests to ensure masks work when out of bounds on all four sides/corners and perhaps even when entirely out of bounds.

@KRLango KRLango requested a review from Ion-e June 17, 2025 10:43
Copy link
Contributor
@lisham2000 lisham2000 left a comment

Choose a reason for hiding this comment

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

Reviewed LGTM with the other PR for context

@cmeyer
Copy link
Collaborator
cmeyer commented Jun 17, 2025

This looks good to me.

But... it's marked as draft? Can you mark it as "Ready for Review" and I'll merge?

@Ion-e Ion-e removed their assignment Jun 18, 2025
@Ion-e Ion-e removed their request for review June 18, 2025 14:44
Copy link
@Ion-e Ion-e left a comment

Choose a reason for hiding this comment

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

This looks good to me!

8000
@KRLango KRLango marked this pull request as ready for review June 18, 2025 14:45
@cmeyer cmeyer merged commit dea5325 into nion-software:master Jun 18, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sprint issue is part of an active sprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0