rank-filters.md 4.61 KB
 Christian Tischer committed Apr 05, 2019 1 2 ``````# Rank filters `````` Christian Tischer committed Apr 05, 2019 3 4 5 6 7 8 ``````## Basic rank filters ### Activity: Explore rank filters on binary images - Open image: xy_8bit_binary__two_spots_different_size.tif `````` Christian Tischer committed Apr 07, 2019 21 ``````- Explore how structures grow and shrink, using erosion and dilation `````` Christian Tischer committed Apr 05, 2019 22 23 24 25 26 27 28 29 `````` ### Activity: Explore rank filters on grayscale images - Open image: xy_8bit__two_noisy_squares_different_size.tif - Explore how a median filter - removes noise - removes small structures - preserves egdes `````` Christian Tischer committed Apr 07, 2019 30 ``````- Compare median filter to mean filter of same radius `````` Christian Tischer committed Apr 05, 2019 31 32 33 34 `````` ### Formative assessment `````` Christian Tischer committed Apr 07, 2019 35 36 37 38 39 40 41 42 43 44 45 ``````True or false? Discuss with your neighbour! 1. Median filter is just another name for mean filter. 2. Small structures can completely disappear from an image when applying a median filter. Fill in the blanks, using those words: shrinks, increases, decreases, enlarges. 1. An erosion _____ objects in a binary image. 2. An erosion in a binary image _____ the number of foreground pixels. 3. A dilation in a grayscale image _____ the average intensity in the image. 4. A dilation _____ objects in a binary image. `````` Christian Tischer committed Apr 05, 2019 46 47 48 49 50 51 52 53 54 55 `````` ## Morphological opening and closing ``` `````` Christian Tischer committed Apr 07, 2019 61 ``````opening( image, r ) = dilation( erosion( image, r ), r ) `````` Christian Tischer committed Apr 05, 2019 62 63 64 ````````` ``` `````` Christian Tischer committed Apr 07, 2019 65 ``````closing( image, r ) = erosion( dilation( image, r ), r ) `````` Christian Tischer committed Apr 05, 2019 66 67 68 69 70 71 ````````` ### Activity: Explore opening and closing on binary images - Open image: xy_8bit_binary__for_open_and_close.tif `````` Christian Tischer committed Apr 07, 2019 72 73 74 ``````- Explore effects of morphological closing and opening: - closing can fill holes - closing can connect gaps `````` Christian Tischer committed Apr 07, 2019 75 `````` - opening can remove thin structures `````` Christian Tischer committed Apr 05, 2019 76 77 78 79 `````` ### Formative assessment `````` Christian Tischer committed Apr 07, 2019 80 ``````True of false? Discuss with your neighbour! `````` Christian Tischer committed Apr 05, 2019 81 `````` `````` Christian Tischer committed Apr 07, 2019 82 83 84 ``````1. Morphological openings on binary images can decrease the number of foreground pixels. 2. Morphological closings on binary images never decreases the number of foreground pixels. 3. Performing a morphological closing a twice in a row does not make sense, because the second closing does not further change the image. `````` Christian Tischer committed Apr 05, 2019 85 86 87 88 89 90 `````` ## Top hat filter for local background subtraction ``` `````` Christian Tischer committed Apr 07, 2019 98 ``````tophat( image ) = image - opening( image, r ) = image - dilation( erosion( image, r), r ) `````` Christian Tischer committed Apr 05, 2019 99 100 ````````` `````` Christian Tischer committed Apr 07, 2019 101 `````` `````` Christian Tischer committed Apr 05, 2019 102 103 104 ``````### Activity: Explore tophat filter - Open image: xy_8bit__spots_local_background.tif `````` Christian Tischer committed Apr 07, 2019 105 ``````- Use a tophat filter to remove local background `````` Christian Tischer committed Apr 05, 2019 106 107 108 `````` ## Activity: Implement a tophat filter `````` Christian Tischer committed Apr 07, 2019 109 ``````- Devise code implementing a tophat filter, using minimum and maximum filters `````` Christian Tischer committed Apr 05, 2019 110 111 112 113 `````` ## Activity: Explore tophat filter on biological data - Open image: xy_16bit__autophagosomes.tif `````` Christian Tischer committed Apr 07, 2019 114 115 116 ``````- Appreciate that you cannot readliy segment the spots. - Use a tophat filter to remove local background. - Threshold the spots in the tophat filtered image. `````` Christian Tischer committed Apr 05, 2019 117 `````` `````` Christian Tischer committed Apr 07, 2019 118 ``````## Activity: Explore tophat filter on noisy data `````` Christian Tischer committed Apr 05, 2019 119 120 121 122 123 124 125 `````` - Open image: xy_8bit__spots_local_background_with_noise.tif - Use topHat filter to remove local background - Appreciate that noise poses a challenge to the tophat filter ## Median filter for local background subtraction `````` Christian Tischer committed Apr 07, 2019 126 `````` ``` median_based_background_correction = image - median( image, r) ``` ### Activity: Implement median based background subtraction - Write code to implement a median based background subtraction ### Activity: Explore median filter for local background subtraction - Open images: - xy_8bit__spots_local_background.tif `````` Christian Tischer committed Apr 07, 2019 149 150 `````` - xy_8bit__spots_local_background_with_noise.tif - Use tophat filter to remove local background `````` Christian Tischer committed Apr 05, 2019 151 152 153 154 ``````- Devise code to implement a tophat filter using basic functions ### Formative assessment `````` Christian Tischer committed Apr 07, 2019 155 156 157 158 159 ``````Answer below questions. Discuss with your neighbour! 1. What could one do to close small gaps in a binary image? 2. What could one do to remove small objects in a image? 3. What could you use for local background subtraction in a very noisy image? `````` Christian Tischer committed Apr 05, 2019 160 `````` `````` Christian Tischer committed Apr 07, 2019 161 ``````## Learn more `````` Christian Tischer committed Apr 05, 2019 162 `````` `````` Christian Tischer committed Apr 07, 2019 163 ``````- https://imagej.net/MorphoLibJ#Grayscale_morphological_filters `````` Christian Tischer committed Apr 05, 2019 164 165 166 `````` ``````