Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 9 Morphological Image Processing

Similar presentations


Presentation on theme: "Chapter 9 Morphological Image Processing"— Presentation transcript:

1 Chapter 9 Morphological Image Processing
國立雲林科技大學 電子工程系 張傳育(Chuan-Yu Chang ) 博士 Office: ES 709 TEL: ext. 4337

2 Introduction Mathematical morphology
A tool for extracting image components that are useful in the representation and description of region shape, such as boundaries, skeletons, and convex hull. Sets in mathematical morphology represent objects in an image. 2D integer space Z2 (x,y) coordinates Z3: gray-scale digital images (x,y) coordinates, and gray-level value

3 Preliminaries Let A be a set in Z2, If a=(a1, a2) is an element of A
If a is not an element of A, we write The set with no elements is called the null or empty set and denoted by the symbol The elements of the sets with which we are concerned are the coordinates of pixels representing objects. Ex: set C is the set of elements, w, such that w is formed by multiplying each of the two coordinates of all the elements of set D by -1. (9.1-1) (9.1-2)

4 Preliminaries Basic Concepts from Set Theory Subset Union Intersection
If every element of a set A is also an element of another set B, then A is said to be a subset of B. Union The set of all elements belonging to either A, B, or both Intersection The set of all elements belonging to both A and B (9.1-3) (9.1-4) (9.1-5)

5 Preliminaries (cont.) Disjoint (mutually excusive) Complement:
If the two set have no common elements Complement: The complement of a set A is the set of elements not contained in A Difference: the set of elements that belong to A, but not to B. (9.1-6) (9.1-7) (9.1-8)

6 Preliminaries (cont.)

7 Preliminaries (cont.) Reflection Translation (9.1-9) (9.1-10)

8 Logic Operations Involving Binary Images
The principal logic operations used in image processing are AND, OR, and NOT The three basic logical operations Performed on a pixel by pixel basis between corresponding pixels of two or more images. Logical operation are restricted to binary variables These operations are functionally complete in the sense that they can be combined to form any other logic operation

9 Logic Operations Involving Binary Images
Black indicates a binary 1 White indicates a 0.

10 Dilation and Erosion For sets A and B in Z2
The dilation of A by B, denoted where set B is referred to as the structuring element. The dilation of A by B is the set of all displacements, z, such that and A overlap by at least on element. (9.2-1) (9.2-2)

11 Dilation and Erosion (cont.)

12 Dilation and Erosion (cont.)
Example of dilation bridging gaps The maximum length of the breaks is known to be two pixels. A simple structuring element that can be used for repairing the gaps is shown in Fig. 9.5(b)

13 Dilation and Erosion For sets A and B in Z2
The erosion of A by B, denoted where set B is referred to as the structuring element. The erosion of A by B is the set of all points z such that B, translated by z, is contained in A.

14 Dilation and Erosion

15 Dilation and Erosion Example of erosion -eliminating irrelevant detail
使用13x13的方形結構,對圖(a)進行erosion 使用13x13的方形結構,對圖(b)進行dilation Example of erosion -eliminating irrelevant detail

16 Opening and Closing Opening
Generally smoothes the contour of an object, breaks narrow isthmuses, and eliminates thin protrusions. The opening A by B is the erosion of A by B, followed by a dilation of the result by B. View the structuring element B as a flat “rolling ball” The boundary of is then established by the points in B that reach the farthest into the boundary of A as B is rolled around the inside of this boundary.

17 Opening and Closing Closing
Tends to smooth sections of contours, fuses narrow breaks and long thin gulfs, eliminates small holes, and fills gaps in the contour. The closing of set A by structuring element B, denoted The closing of A by B is simply the dilation of A by B, followed by the erosion of the result by B.

18 Opening and Closing

19 Opening and Closing The opening operation satisfies the following properties AB is a subset of A If C is a subset of D, then C  B is a subset of D °B (A  B)  B=A  B

20 Opening and Closing The properties of closing operation
A is a subset of AB If C is a subset of D, then C  B is a subset of D  B (A  B)  B=A  B Multiple openings or closings of a set have no effect after the operator has been applied once.

21 Opening and Closing

22 The Hit-or-Miss Transformation
The morphological hit-or-miss transform is a tool for shape detection. If B denotes the set composed of A and its background, the match of B in A, denoted A⊛B , is A⊛B = (A⊝X)∩[Ac⊝(W-X)] Let B=(B1, B2), where B1 is the set formed from elements of B associated with an object and B2 is the set of elements of B associated with the corresponding background. Let B1 =X and B2 =(W-X), Eq. (9.4-1) becomes A⊛B = (A⊝B1)∩[Ac⊝B2] Thus, set A⊛B contains all the (origin) points at which, simultaneously, B1 founded a match (“hit”) in A and B2 found a match in Ac. 在A中找B (9.4-1) 令B=(B1, B2) B1為欲detect的object B2為background (9.4-2)

23 The Hit-or-Miss Transformation
By using the definition of set differences given in Eq(9.1-8) and the relationship between erosion and dilation given in Eq.(9.2-4), we can write Eq.(9.4-2) as A⊛B = (A⊝B1) – (A⊕B2) We refer to any of the preceding three equations as the morphological hit-or-miss transformation. (9.4-3)

24 The Hit-or-Miss Transformation
The objective is to find the location of one of the shapes, say, X. Let the origin of each shape be located at its center of gravity. Let X be enclosed by a small window, W. The local background of X with respect to W is defined as the et difference (W-X), as Fig. (b). Fig. (c) shows the complement of A Fig. (d) shows the erosion of A by X. AӨX may be viewed geometrically as the set of all locations of the origin X at which X found a match (hit) in A. Fig. (e) shows the erosion of the complement of A by the local background set (W-X). From Fig. (d) and (e), the set of locations for which X exactly fits inside A is the intersection of the erosion of A by X and the erosion of Ac by (W-X) as shown in Fig. (f). 將X用W包起來 A經X erosion AC經(W-X) erosion

25 Some basic Morphological Algorithm
Boundary extraction The boundary of a set A can be obtained by first eroding A by B and then performing the set difference between A and its erosion Using a 5x5 structuring element of 1’s would result in a boundary between 2 and 3 pixels thick. When the origin of B is on the edges of the set, part of the structuring element may be outside the image. Assume that the values outside the borders of the image are 0. (9.5-1)

26 Some basic Morphological Algorithm
Fig. 9.14 The structuring element as shown in Fig. 9.13(b). Binary 1’s are shown in white and 0’s in black. The boundary shown in Fig. 9.14(b) is one pixel thick.

27 Some basic Morphological Algorithm
Region Filling In Fig. 9.15, A denotes a set containing a subset whose elements are 8-connected boundary points of a region. Beginning with a point p inside the boundary, the objective is to fill the entire region with 1’s. Assume that all non-boundary points are labeled 0. Assign a value of 1 to p to begin. The following procedure then fills the region with 1’s: where X0=p, and B is the symmetric structuring elements shown in Fig. 9.15(c). The algorithm terminates at iteration step k if Xk=Xk-1. The set union of Xk and A contains the filled set and its boundary.

28 Some basic Morphological Algorithm
Example 9.6: Morphological region filling An image composed of white circles with black inner spots. The objective is to eliminate the reflections by region filling. Starting point

29 Some basic Morphological Algorithm
Extraction of Connected Components Let Y represent a connected component contained in a set A and assume that a point p of Y is known. The following iterative expression yields all the elements of Y: where X0=p, and B is a suitable structuring element, as shown in Fig If Xk=Xk-1, the algorithm has converged and we let Y=Xk. (9.5-3)

30 Some basic Morphological Algorithm
Example 9.7: Used for automated inspection. Fig. 9.18(a) shows an X-ray image of a chicken breast that contains bone fragments. To detect foreign objects in processed food before packaging or shipping.

31 Some basic Morphological Algorithm
Convex Hull A set A is said to be convex if the straight line segment jointing any two points in A lies entirely within A. The convex hull H of an arbitrary set S is the smallest convex set containing S. The set difference H-S is called the convex deficiency of S. The convex hull and convex deficiency are useful for object description. Let Bi, i=1, 2, 3, 4, represent the four structuring elements in Fig (a). The procedure consists of implementing the equation: where Let Then the convex hull of A is (9.5-4) (9.5-5)

32 Some basic Morphological Algorithm
X indicates don’t care The procedure consists of iteratively applying the hit-or-miss transform to A with B1; when no further changes occur, we perform the union with A and call the result D1. The procedure is repeated with B2 until no further changes occur, and so on. The union of the four resulting D’s constitutes the convex hull of A.

33 Some basic Morphological Algorithm

34 Some basic Morphological Algorithm
The thinning of a set A by a structuring element B, denoted by A ⊗ B, can be defined by the hit-or-miss transform: A ⊗ B = A-(A⊛B) = A∩(A ⊛B)c A more useful expression for thinning A symmetrically is based on a sequence of structuring elements: where Bi is a rotated version of Bi-1 Based on the concept, the thinning can be defined by a sequence of structuring element The process is to thin A by one pass with B1, then thin the result with one pass of B2, and so on, until A is thinned with one pass of Bn. The entire process is repeated until no further changes occur. (9.5-6) (9.5-7) (9.5-8)

35 Some basic Morphological Algorithm

36 Some basic Morphological Algorithm (cont.)
Thickening Thickening is the morphological dual of thinning and is defined by A⊙B = A∪(A⊛B) where B is a structuring element suitable for thickening. As in thinning , thickening can be defined as a sequential operation: A⊙{B} =((…((A⊙B1) ⊙B2)…) ⊙Bn) The structuring elements used for thickening have the same form as those shown in Fig. 9.21(a) in connection with thinning, but with all 1’s and 0’s interchanged. The usual procedure is to thin the background of the set in question and then complement the result.(欲使某集合變粗,可細化該集合的背景後,取其背景的補集。) Thicken a set A, we form C=Ac, thin C, and then form Cc. (9.5-9) (9.5-10)

37 Some basic Morphological Algorithm
Thickening by background thinning Thicken a set A, we form C=Ac, thin C, and then form Cc. 欲使某集合變粗,可細化該集合的背景後,取其背景的補集。 欲粗化集合A的步驟: 先求A的背景,C=Ac 細化 C 求C的補集,Cc

38 Some basic Morphological Algorithm (cont.)
Skeletons As shown in Fig. 9.23, the notation of a skeleton, S(A), of a set A is intuitively simple. We deduce from this figure that If z is a point of S(A) and (D)z is the largest disk centered at z and contained in A, one cannot find a larger disk containing (D)z and included in A. The disk (D)z is called a maximum disk. The disk (D)z touches the boundary of A at two or more different places.

39 Some basic Morphological Algorithm (cont.)
Skeletons The skeleton of A can be expressed in terms of erosions and openings: with where B is a structuring element, and (A⊖kB) indicates k successive erosions of A: (9.5-11) (9.5-12) 表示A經過k次B的侵蝕 (9.5-13)

40 Some basic Morphological Algorithm (cont.)
K is the last iterative step before A erodes to an empty set. In other words, (A被B侵蝕成空集合前的最後一次侵蝕) The formulation given in Eqs.(9.5-11) and (9.5-12) states that S(A) can be obtained as the union of the skeleton subsets Sk(A). A can be reconstructed from these subsets by using the equation.(集合A可由其骨架子集合Sk(A) ,經過k次膨脹(dilation)後復原。) where (Sk(A)⊕kB) denotes k successive dilations of Sk(A) (9.5-14) (9.5-15) (9.5-16)

41 Basic morphological Algorithm

42 Basic morphological Algorithm (cont.)
修剪(Pruning) Since thinning and skeletonizing algorithms tend to leave parasitic components that need to be “cleaned up” by post-processing. Assumptions: Assume that the length of a parasitic component does not exceed a specified number of pixels. The solution is based on suppressing a parasitic branch by successively eliminating its end point. Thinning of an input set A with a sequence of structuring elements designed to detect only end points achieves the desired result. Let where {B} denotes the structuring element sequence shown in Fig. 9.25(b) and (c). The sequence of structuring elements consists of two different structures, each of which is rotated 90° for a total of eight elements. (9.5-17)

43 Basic morphological Algorithm (cont.)
Applying Eq(9.5-17) to A three times yields the set X1 shown in Fig. 9.25(d). The next step is to “restore” the character to its original form, but with the parasitic branches removed. Forming a set X2 containing all end points in X where the Bk are the same end-point detectors shown in Figs. 9.25(b) and (c). The next step is dilation of the end points three times, using set A as a delimiter: X3=(X2⊕H)∩A where H is a 3x3 structuring element of 1’s. Finally, the union of X3 and X1 yields the desired result, X4 = X1∪ X3 (9.5-18) (9.5-19) (9.5-20)

44 Basic morphological Algorithm
修剪(Pruning) 由於細化及骨架化後,常會遺留一些小分支,需清除,因此需要修剪演算法。 基本觀念: 假設parasitic component的長度不超過一特定值,pruning的做法在於藉由連續的刪減端點(end point) ,來減少寄生分枝。 作法: 將集合A 經過結構元素B的細化,X1 找出 A的end point,X2 對X2進行dilation,X3 取X1和 X3的聯集。

45 Basic morphological Algorithm (cont.)

46 Summary of Morphological Operations on Binary Images

47 Summary of Morphological Operations on Binary Images (cont.)

48 Summary of Morphological Operations on Binary Images (cont.)

49 Summary of Morphological Operations on Binary Images (cont.)

50 Summary of Morphological Operations on Binary Images (cont.)

51 Extensions to gray-scale images
In this section, we extend to gray-scale images the basic operations of dilation, erosion, opening, and closing. Define: f(x,y): input image b(x,y): structuring element These functions are discrete, ie., if Z denotes the set of real integers, the assumption is that (x,y) are integers from ZxZ and that f and b are functions that assign a gray-level value to each distinct pair of coordinates (x,y). Dilation (f被b的灰階膨脹) Gray-scale dilation of f by B, denoted f⊕b, is defined as Where Df and Db are the domains of f and b, respectively.

52 Extensions to gray-scale images (cont.)
By means of 1-D function, Eq.(9.6-1) reduces to The function f(-x) is simply f(x) mirrored with respect to the origin of the x axis. The function f(s-x) moves to the right for positive s, and to the left for negative s. The requirements that the value of (s-x) has to be in the domain of f and that the value of x has to be in the domain of b imply that f and b overlap. where the two sets have to overlap by at least one element. F sliding by b is really no different than b sliding by f. The actual mechanics of gray-scale dilation are easier to visualize if b is the function that slides past f.

53 Extensions to gray-scale images (cont.)
At each position of the structuring element the value of dilation at that point is the maximum of the sum of f and b in the interval spanned by b.

54 Extensions to gray-scale images (cont.)
The general effect of performing dilation on a gray-scale images is: If all the values of the structuring element are positive, the output image tends to be brighter than the input. Dark details either are reduced or eliminated, depending on how their values and shapes relate to the structuring element used for dilation. Dilation後產生的影像會比原始影像明亮,且小的深色細節會被減少或移除。

55 Extensions to gray-scale images (cont.)
Erosion (f被b侵蝕) Erosion後產生的影像會比原始影像暗,且小的明亮細節會被減少或移除。

56 Extensions to gray-scale images
Flat-top structuring element in the shape of a parallelepiped of unit height and size 5*5 pixels

57 Extensions to gray-scale images (cont.)
The general effect of performing erosion on a gray-scale images is: If all the elements of the structuring element are positive, the output image tends to be darker than the input. The effect of bright details in the input image that are smaller in area than the structuring element is reduced. Erosion後產生的影像會比原始影像暗,且小的明亮的特徵會降低。

58 Extensions to gray-scale images
Opening and Closing The expressions for opening and closing of gray-scale images have the same form as their binary counterparts. The erosion of f by b, followed by a dilation of the result by b. Opening: The dilation of f by b, followed by a erosion of the result by b. Closing: The opening and closing for gray-scale images are duals with respect to complementation and reflection In practical applications, Opening operations usually are applied to remove small light details, while leaving the overall gray levels and large bright features relatively undisturbed. Closing is generally used to remove dark details from an image, while leaving bright features relatively undisturbed

59 Extensions to gray-scale images

60 Extensions to gray-scale images
The gray-scale opening operation satisfies the following properties: Similarly, the closing operation satisfies the following properties:

61 Extensions to gray-scale images

62 Extensions to gray-scale images
Some applications of gray-scale morphology Morphological smoothing Morphological gradient Top-hat transformation Textural segmentation Granulometry

63 Extensions to gray-scale images
Morphological smoothing To perform a morphological opening followed by a closing. (先對原始影像執行closing,再執行opening。) The net result of these two operations is to remove or attenuate both bright and dark artifacts or noise.

64 Extensions to gray-scale images
Morphological gradient The morphological gradient highlights sharp gray-level transitions in the input image. Morphological gradients obtained using symmetrical structuring elements tend to depend less on edge directionality. 使用對稱的結構元素的morphological gradient,和edge的方向性的關聯較少。(與影像的二階微分相比)

65 Extensions to gray-scale images
Morphological Top-hat transformation where f is the input image and b is the structuring element function. This transformation is useful for enhancing detail in the presence of shading. (對於強化shading的細節相當有用)

66 Extensions to gray-scale images
Textural segmentation The objective is to find the boundary between the two regions based on their textural content. Because closing tends to remove dark details from an image, the procedure in this particular case is to close the input image by using successively larger structuring elements. When the size of the structuring element corresponds to that of the small blobs, they are removed from the image, leaving only a light background. A single opening is performed with a structuring element that is large in relation to the separation between the large blobs. Removes the light patches between the blobs, leaving a dark region on the right consisting of the large dark blobs and now equally dark patches between these blobs. A simple threshold the yields the boundary between the two textual regions.

67 Extensions to gray-scale images
對原始圖進行一連串的closing,(結構元素逐次變大) 進行一次的opening(結構元素的大小約為大圓的間距) Thresholding以分隔左右邊。

68 Extensions to gray-scale images (cont.)
Granulometry Granulometry is a field that deals principally with determining the size distribution of particles in an image. Fig (a) shows an image consisting of light objects of three different size. Because the particles are lighter than the background, the following morphological approach can be used to determine size distribution. Opening operation with structuring elements of increasing size are performed on the original image. The difference between the original image and its opening is computed after each pass when a different structuring element is completed. These differences are normalized and then used to construct a histogram of particle-size distribution.

69 Extensions to gray-scale images
Granulometry This approach is based on the idea that opening operations of a particular size have the most effect on regions of the input image that contain particles of similar size. A measure of the relative number of such particles is obtained by computing the difference between the input and output images.


Download ppt "Chapter 9 Morphological Image Processing"

Similar presentations


Ads by Google