Commit cef2871
fix(hilbert): support offset-centre circular masks
Previously Hilbert image-mesh raised PixelizationException for offset-centre
circular masks whose centres didn't land on a pixel half-integer, and would
have silently sampled the wrong region of the image for those that slipped
through. This commit fixes both halves of the bug.
- Mask2D.is_circular rewritten to be quantization-robust: bbox square within
one pixel, geometric centre pixel unmasked, and a reference circular mask
reconstructed from the inferred centre+radius must match the input within
rim quantization tolerance. The new predicate correctly accepts offset
circles and rejects annular and square masks that previously false-passed.
- Mask2D.circular_radius now derives the radius from the bbox extent rather
than the central row count. Numerically identical for centred masks; correct
for offset centres.
- hilbert.image_and_grid_from now translates Hilbert sample points by
mask_centre, so the curve actually probes the masked region of the image.
For masks centred at the origin (every current test/smoke case) the shift
is a no-op and likelihoods are bit-identical.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 3ddf368 commit cef2871
4 files changed
Lines changed: 160 additions & 19 deletions
File tree
- autoarray
- inversion/mesh/image_mesh
- mask
- test_autoarray
- inversion/pixelization/image_mesh
- mask
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
125 | 131 | | |
126 | 132 | | |
127 | 133 | | |
| |||
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
| 154 | + | |
148 | 155 | | |
149 | 156 | | |
150 | 157 | | |
| |||
271 | 278 | | |
272 | 279 | | |
273 | 280 | | |
| 281 | + | |
274 | 282 | | |
275 | 283 | | |
276 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
938 | 938 | | |
939 | 939 | | |
940 | 940 | | |
941 | | - | |
| 941 | + | |
942 | 942 | | |
943 | | - | |
944 | | - | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
945 | 958 | | |
946 | 959 | | |
947 | 960 | | |
| |||
955 | 968 | | |
956 | 969 | | |
957 | 970 | | |
958 | | - | |
959 | | - | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
960 | 1006 | | |
961 | 1007 | | |
962 | | - | |
963 | | - | |
964 | | - | |
965 | | - | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
966 | 1011 | | |
967 | 1012 | | |
968 | 1013 | | |
969 | 1014 | | |
970 | 1015 | | |
971 | 1016 | | |
972 | | - | |
973 | | - | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
974 | 1020 | | |
975 | 1021 | | |
976 | 1022 | | |
| |||
987 | 1033 | | |
988 | 1034 | | |
989 | 1035 | | |
990 | | - | |
| 1036 | + | |
991 | 1037 | | |
992 | 1038 | | |
993 | 1039 | | |
994 | 1040 | | |
995 | | - | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
1000 | 1045 | | |
1001 | | - | |
| 1046 | + | |
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
705 | 705 | | |
706 | 706 | | |
707 | 707 | | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
0 commit comments