Presentation is loading. Please wait.

Presentation is loading. Please wait.

Binary Morphology A method for … –Dilation –Erosion –Opening –Closing -750-

Similar presentations


Presentation on theme: "Binary Morphology A method for … –Dilation –Erosion –Opening –Closing -750-"— Presentation transcript:

1 Binary Morphology A method for … –Dilation –Erosion –Opening –Closing -750-

2 Dilation The dilation operator takes two pieces of data as input –A binary image, which is to be dilated –A structuring element (or kernel), which determines the behavior of the morphological operation Suppose that X is the set of Euclidean coordinates of the input image, and K is the set of coordinates of the structuring element Let Kx denote the translation of K so that its origin is at x. The DILATION of X by K is simply the set of all points x such that the intersection of Kx with X is non-empty -751-

3 Erosion -752-

4 Dilation Example: Suppose that the structuring element is a 3x3 square with the origin at its center { (-1,-1), (0,-1), (1,-1), (-1,0), (0,0), (1,0), ( 1,1), (0,1), (1,1) } 111 111 111 X = K = -753-

5 Dilation Example: Suppose that the structuring element is a 3x3 square with the origin at its center Note: Foreground pixels are represented by a color and background pixels are empty -754-

6 Dilation output Structuring element Input -755-

7 Dilation output -756-

8 Dilation output -757-

9 Dilation -758-

10 Dilation -759-

11 Erosion Erosion is the dual of dilation i.e. eroding foreground pixels is equivalent to dilating the background pixels. -760-

12 Erosion To compute the erosion of a binary input image by the structuring element For each foreground pixel superimpose the structuring element If for every pixel in the structuring element, the corresponding pixel in the image underneath is a foreground pixel, then the input pixel is left as it is Otherwise, if any of the corresponding pixels in the image are background, however, the input pixel is set to background value -761-

13 Erosion -762-

14 Erosion -763-

15 Erosion -764-

16 Erosion -765-

17 Opening & Closing Opening and Closing are two important operators from mathematical morphology They are both derived from the fundamental operations of erosion and dilation They are normally applied to binary images -766-

18 Opening Opening is defined as an erosion followed by a dilation using the same structuring element The basic effect of an opening is similar to erosion Tends to remove some of the foreground pixels from the edges of regions of foreground pixels Less destructive than erosion The exact operation is determined by a structuring element. -767-

19 Opening Erosion can be used to eliminate small clumps of undesirable foreground pixels, e.g. “salt noise” However, it affects all regions of foreground pixels indiscriminately Opening gets around this by performing both an erosion and a dilation on the image -768-

20 Closing Closing, like its dual operator opening, is derived from the fundamental operations of erosion and dilation. Normally applied to binary images Tends to enlarge the boundaries of foreground regions Less destructive of the original boundary shape The exact operation is determined by a structuring element. -769-

21 Closing Closing is opening performed in reverse. It is defined simply as a dilation followed by an erosion using the same -770-

22 Closing -771-

23 -772-

24 Detecting a Cell Using Image Segmentation -773-

25 Step 1: Read Image Read in 'cell.tif', which is an image of a prostate cancer cell. I = imread('cell.tif'); figure, imshow(I), title('original image'); -774-

26 Step 2: Rescale the Image We use the imadjust function to rescale the image so that it covers the entire dynamic range ([0,1]). DI = imadjust(I, [], [0 1]); figure, imshow(DI), title('scaled image'); -775-

27 Step 3: Detect Entire Cell Two cells are present in this image, but only one cell can be seen in its entirety. We will detect this cell. Another word for object detection is segmentation. The object to be segmented differs greatly in contrast from the background image. Changes in contrast can be detected by operators that calculate the gradient of an image. One way to calculate the gradient of an image is the Sobel operator, which creates a binary mask using a user-specified threshold value.We determine a threshold value using the graythresh function. To create the binary gradient mask, we use the edge function. -776-

28 BWs = edge(DI, 'sobel', (graythresh(DI) *.1)); figure, imshow(BWs), title('binary gradient mask'); -777-

29 Step 4: Fill Gaps The binary gradient mask shows lines of high contrast in the image. These lines do not quite delineate the outline of the object of interest. Compared to the original image, you can see gaps in the lines surrounding the object in the gradient mask. These linear gaps will disappear if the Sobel image is dilated using linear structuring elements, which we can create with the strel function. se90 = strel('line', 3, 90); se0 = strel('line', 3, 0); -778-

30 Step 5: Dilate the Image The binary gradient mask is dilated using the vertical structuring element followed by the horizontal structuring element. The imdilate function dilates the image. BWsdil = imdilate(BWs, [se90 se0]); figure, imshow(BWsdil), title('dilated gradient mask'); -779-

31 Step 6: Fill Interior Gaps The dilated gradient mask shows the outline of the cell quite nicely, but there are still holes in the interior of the cell. To fill these holes we use the imfill function. BWdfill = imfill(BWsdil, 'holes'); figure, imshow(BWdfill); title('binary image with filled holes'); -780-

32 Step 7: Remove Connected Objects on Border The cell of interest has been successfully segmented, but it is not the only object that has been found. Any objects that are connected to the border of the image can be removed using the imclearborder function. The connectivity in the imclearborder function was set to 4 to remove diagonal connections. BWnobord = imclearborder(BWdfill, 4); figure, imshow(BWnobord), title('cleared border image'); -781-

33 Step 8: Smooth the Object Finally, in order to make the segmented object look natural, we smooth the object by eroding the image twice with a diamond structuring element. We create the diamond structuring element using the strel function. seD = strel('diamond',1); BWfinal = imerode(BWnobord,seD); BWfinal = imerode(BWfinal,seD); figure, imshow(BWfinal), title('segmented image'); -782-

34 BWoutline = bwperim(BWfinal); Segout = imadd(I, immultiply(BWoutline, 255)); figure, imshow(Segout), title('outlined original image'); -783-


Download ppt "Binary Morphology A method for … –Dilation –Erosion –Opening –Closing -750-"

Similar presentations


Ads by Google