1 / 43

Binary Morphology

Binary Morphology. A method for … Dilation Erosion Opening Closing. -750-. 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

Download Presentation

Binary Morphology

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 -754- Note: Foreground pixels are represented by a color and background pixels are empty

  5. Dilation Structuring element Input -755- 1 2 3 output

  6. Dilation -756- 4 5 6 output

  7. Dilation -757- 7 8 9 output

  8. Dilation -757- 10 11 12 output

  9. Dilation -758-

  10. Example. 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 1 -763- 2 3

  15. Erosion 4 -763- 5

  16. Erosion 6 -763- 7 8

  17. Erosion 9 -763- 10

  18. Erosion 11 -763- 12 13

  19. Erosion 14 -763- 15

  20. Erosion 16 -763- 17 18

  21. Erosion 19 -763- 20

  22. Erosion 21 -763- 22 23

  23. Erosion 24 -763- 25

  24. Erosion -763-

  25. Erosion -765-

  26. 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-

  27. 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-

  28. 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-

  29. 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-

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

  31. Closing -771-

  32. -772-

  33. Detecting a Cell Using Image Segmentation -773-

  34. 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-

  35. 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-

  36. 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-

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

  38. 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-

  39. 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-

  40. 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-

  41. 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 imclearborderfunction. 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-

  42. 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-

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

More Related