|
5 | 5 | adaptive_threshold_bright, |
6 | 6 | invert_image, |
7 | 7 | percentile_threshold, |
8 | | - resize_mask, |
9 | 8 | rolling_ball_background, |
10 | 9 | simple_thresholding, |
11 | 10 | ) |
12 | 11 |
|
13 | 12 |
|
14 | 13 | class TestSkimageFilters: |
15 | | - def test_resize_mask_nearest(self): |
16 | | - """Test resizing a mask with nearest-neighbor interpolation preserves mask integrity.""" |
17 | | - mask = np.zeros((10, 10), dtype=np.uint8) |
18 | | - mask[2:8, 2:8] = 1 |
19 | | - output_shape = (20, 20) |
20 | | - resized = resize_mask(mask, output_shape=output_shape) |
21 | | - assert resized.shape == output_shape |
22 | | - # Should only contain 0 and 1 |
23 | | - assert set(np.unique(resized)).issubset({0, 1}) |
24 | | - # Check that the central region is still 1 |
25 | | - assert np.sum(resized == 1) > 0 |
| 14 | + |
| 15 | + def test_resize_labels(self): |
| 16 | + """Test resizing a label image by scale factor preserves label values and shape.""" |
| 17 | + from napari_tmidas.processing_functions.skimage_filters import ( |
| 18 | + resize_labels, |
| 19 | + ) |
| 20 | + |
| 21 | + label_image = np.zeros((10, 10), dtype=np.uint8) |
| 22 | + label_image[2:8, 2:8] = 3 |
| 23 | + scale_factor = 0.5 |
| 24 | + scaled = resize_labels(label_image, scale_factor=scale_factor) |
| 25 | + expected_shape = tuple( |
| 26 | + (np.array(label_image.shape) * scale_factor).astype(int) |
| 27 | + ) |
| 28 | + assert scaled.shape == expected_shape |
| 29 | + # Should only contain 0 and 3 |
| 30 | + assert set(np.unique(scaled)).issubset({0, 3}) |
| 31 | + # Check that the central region is still present |
| 32 | + assert np.sum(scaled == 3) > 0 |
26 | 33 |
|
27 | 34 | def test_invert_image_basic(self): |
28 | 35 | """Test basic image inversion functionality""" |
|
0 commit comments