File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 resize_mask ,
99 rolling_ball_background ,
1010 simple_thresholding ,
11- white_tophat ,
1211)
1312
1413
@@ -89,20 +88,6 @@ def test_simple_thresholding_different_thresholds(self):
8988class TestBrightRegionExtraction :
9089 """Test suite for bright region extraction functions"""
9190
92- def test_white_tophat_basic (self ):
93- """Test white top-hat transform extracts bright features"""
94- # Create image with bright spot on dark background
95- image = np .zeros ((100 , 100 ), dtype = np .uint8 )
96- image [40 :60 , 40 :60 ] = 200 # Bright square
97- image [45 :55 , 45 :55 ] = 255 # Brighter center
98-
99- result = white_tophat (image , footprint_size = 15 )
100-
101- # Result should have bright features extracted
102- assert result .shape == image .shape
103- assert result .max () > 0 # Should have some bright regions
104- assert result .sum () < image .sum () # Background removed
105-
10691 def test_percentile_threshold_original (self ):
10792 """Test percentile thresholding with original values"""
10893 # Create image with gradient
Original file line number Diff line number Diff line change @@ -521,48 +521,6 @@ def convert_to_uint8(image: np.ndarray) -> np.ndarray:
521521
522522if SKIMAGE_AVAILABLE :
523523
524- @BatchProcessingRegistry .register (
525- name = "White Top-Hat (Extract Bright Features)" ,
526- suffix = "_tophat" ,
527- description = "Extract bright features from background using morphological white top-hat transform" ,
528- parameters = {
529- "footprint_size" : {
530- "type" : int ,
531- "default" : 15 ,
532- "min" : 3 ,
533- "max" : 101 ,
534- "description" : "Size of structuring element (larger removes bigger background features)" ,
535- }
536- },
537- )
538- def white_tophat (
539- image : np .ndarray , footprint_size : int = 15
540- ) -> np .ndarray :
541- """
542- Apply white top-hat transform to extract bright regions.
543-
544- The white top-hat transform extracts bright features that are smaller than
545- the structuring element. It works by subtracting a morphological opening
546- from the original image, effectively removing background and keeping only
547- bright peaks and spots.
548-
549- Parameters:
550- -----------
551- image : numpy.ndarray
552- Input image array
553- footprint_size : int
554- Size of the structuring element (disk). Larger values remove broader
555- background variations and keep only the brightest local features.
556-
557- Returns:
558- --------
559- numpy.ndarray
560- Image with bright features extracted and background removed
561- """
562- # Create circular structuring element
563- footprint = skimage .morphology .disk (footprint_size )
564- return skimage .morphology .white_tophat (image , footprint = footprint )
565-
566524 @BatchProcessingRegistry .register (
567525 name = "Percentile Threshold (Keep Brightest)" ,
568526 suffix = "_percentile" ,
You can’t perform that action at this time.
0 commit comments