Skip to content

Commit 434c4c3

Browse files
committed
Add polygonal ROI to image ROI tests and update assertions
1 parent 7cc242c commit 434c4c3

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

cdl/tests/features/common/roi_app_test.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@
3636
# Image ROIs:
3737
IROI1 = [SIZE // 2, SIZE // 2, SIZE - 25 - SIZE // 2, SIZE - SIZE // 2] # Rectangle
3838
IROI2 = [SIZE // 3, SIZE // 2, SIZE // 4] # Circle
39+
IROI3 = [
40+
SIZE // 2,
41+
SIZE // 2,
42+
SIZE // 2,
43+
SIZE - SIZE // 4,
44+
SIZE - SIZE // 4,
45+
SIZE - SIZE // 3,
46+
] # Polygon (triangle, that is intentionally inside the rectangle, so that this ROI
47+
# has no impact on the mask calculations in the tests)
3948

4049

4150
def __run_signal_computations(panel: SignalPanel, singleobj: bool | None = None):
@@ -162,7 +171,7 @@ def __run_image_computations(panel: ImagePanel, singleobj: bool | None = None):
162171
roisham = "ROI shape mismatch"
163172

164173
if singleobj is None or not singleobj: # Multiple objects mode
165-
assert len(panel) == obj_nb + 2, "Two objects expected"
174+
assert len(panel) == obj_nb + 3, "Three objects expected"
166175
im1, im2 = panel[obj_nb + 1], panel[obj_nb + 2]
167176
assert np.all(im1.data != 0), nzroi
168177
assert im1.data.shape == (IROI1[3], IROI1[2]), roisham
@@ -211,6 +220,7 @@ def create_test_image_with_roi(
211220
ima.data += 1 # Ensure that the image has non-zero values (for ROI check tests)
212221
roi = dlo.create_image_roi("rectangle", IROI1)
213222
roi.add_roi(dlo.create_image_roi("circle", IROI2))
223+
roi.add_roi(dlo.create_image_roi("polygon", IROI3))
214224
ima.roi = roi
215225
return ima
216226

doc/images/shots/i_roi_image.png

7.14 KB
Loading

doc/images/shots/s_roi_signal.png

1.91 KB
Loading

0 commit comments

Comments
 (0)