|
3 | 3 |
|
4 | 4 | from napari_tmidas.processing_functions.skimage_filters import ( |
5 | 5 | adaptive_threshold_bright, |
6 | | - h_maxima_transform, |
7 | 6 | invert_image, |
8 | 7 | percentile_threshold, |
| 8 | + resize_mask, |
9 | 9 | rolling_ball_background, |
10 | 10 | simple_thresholding, |
11 | 11 | white_tophat, |
12 | 12 | ) |
13 | 13 |
|
14 | 14 |
|
15 | 15 | class TestSkimageFilters: |
| 16 | + def test_resize_mask_nearest(self): |
| 17 | + """Test resizing a mask with nearest-neighbor interpolation preserves mask integrity.""" |
| 18 | + mask = np.zeros((10, 10), dtype=np.uint8) |
| 19 | + mask[2:8, 2:8] = 1 |
| 20 | + output_shape = (20, 20) |
| 21 | + resized = resize_mask(mask, output_shape=output_shape) |
| 22 | + assert resized.shape == output_shape |
| 23 | + # Should only contain 0 and 1 |
| 24 | + assert set(np.unique(resized)).issubset({0, 1}) |
| 25 | + # Check that the central region is still 1 |
| 26 | + assert np.sum(resized == 1) > 0 |
| 27 | + |
16 | 28 | def test_invert_image_basic(self): |
17 | 29 | """Test basic image inversion functionality""" |
18 | 30 | image = np.random.rand(100, 100) |
@@ -134,21 +146,6 @@ def test_rolling_ball_background_subtraction(self): |
134 | 146 | # Center of bright spot should be brighter in result than in corners |
135 | 147 | assert result[50, 50] > result[10, 10] |
136 | 148 |
|
137 | | - def test_h_maxima_transform(self): |
138 | | - """Test H-maxima transform suppresses small peaks""" |
139 | | - # Create image with peaks of different heights |
140 | | - image = np.zeros((100, 100), dtype=np.uint8) |
141 | | - image[20, 20] = 100 # Small peak |
142 | | - image[50, 50] = 200 # Large peak |
143 | | - image[80, 80] = 80 # Very small peak |
144 | | - |
145 | | - result = h_maxima_transform(image, h=50.0) |
146 | | - |
147 | | - # Should suppress small peaks, keep large ones |
148 | | - assert result.shape == image.shape |
149 | | - # Large peak should remain prominent |
150 | | - assert result[50, 50] > result[20, 20] |
151 | | - |
152 | 149 | def test_adaptive_threshold_bright(self): |
153 | 150 | """Test adaptive thresholding with bright bias""" |
154 | 151 | # Create image with varying brightness |
|
0 commit comments