1.33k likes | 2.04k Views
Mathematical Morphology in Image Processing. Dr.K.V.Pramod Dept. of Computer Applications Cochin University of Sc. & Technology. What is Mathematical Morphology ?. An (imprecise) Mathematical answer :.
E N D
Mathematical MorphologyinImage Processing Dr.K.V.Pramod Dept. of Computer Applications Cochin University of Sc. & Technology
An (imprecise) Mathematical answer : • A mathematical tool for investigating geometric structure in binary and grayscale images.
Applications Image Processing and Analysis A (precise) Mathematical Answer Algebra Complete Lattices Topology Hit-or-Miss • A mathematical tool that studies operators on complete lattices Mathematical Morphology Operators Erosions-Dilations Geometry Convexity - Connectivity Distance
With in Biology, the term morphology is used for the study of the shape and structure of animals and plants. • In image processing Mathematical morphology is theoretical framework for representation, description and pre-processing
Built on Minkowski set theory. • Part of the theory of finite lattices. • A mathematical theory or methodology for nonlinear image processing. • A technique for image analysis based on shape. • Extremely useful, yet not often used
Morphology - advantages • Preserves edge information • Works by using shape-based processing • Can be designed to be idempotent • Computationally efficient
Morphology - applications • Image enhancement • Image restoration (eg. Removing scratches from digital film) • Edge detection • Texture analysis • Noise reduction There are many more applications that morphology can be applied to. Morphology has been widely researched for use in image and video processing.
Some History Mathematical morphology was developed in the 1970’s by George Matheron and Jean Serra - George Matheron (1975)Random Sets and Integral Geometry, John Wiley. • Jean Serra (1982)Image Analysis and Mathematical Morphology, Academic Press. • Petros Maragos (1985)A Unified Theory of Translations-Invariant Systems with Applications to Morphological Analysis and Coding of Images, Doctoral Thesis, Georgia Tech.
Why we use these techniques ?:Shape Processing and Analysis • Visual perception requires transformation of images so as to make explicit particular shape information. • Goal: Distinguish meaningful shape information from irrelevant one. • The vast majority of shape processing and analysis techniques are based on designing a shape operator which satisfies desirable properties.
Grayscale Images Binary Images Example • Image analysis consists of obtaining measurements characteristic to images under consideration. • Geometric measurements (e.g., object location, orientation, area, length of perimeter)
Mathematical Morphology • Principles: • Such further processing is performed using one or a combination of several morphological transformations. • The transformations work in a certain local neighborhood of each pixel (similarly to convolution) defined by so called ‘Structuring Element ‘. The structuring element can be square, cross-like or any other shape.
Mathematical Morphology: Binary ImagesMorphology usesSet Theory as foundation for many functions. The simplest functions to implement are Dilation and Erosion • Dilation • Dilation replaces zeros neighboring to ones by ones. • Erosion • Erosion replaces ones neighboring to zeros by zeros.
Two other basic operations are - • Closing & Opening • Closing • Closing is dilation followed by erosion. • Closing merges dense of ones together, fills small • holes and smoothes boundaries. • Closing smoothes objects by adding pixels • Opening • Opening is erosion followed by dilation. • Opening removes single ones, thin lines and divides objects connected with a narrow path (neck). • Opening smoothes objects by removing pixels
Common names: Dilate, Grow, Expand Dilation (I) • Brief Description • One of the two basic operators • Basic effect • Gradually enlarge the boundaries of regions of foreground pixels on a binary image.
Dilation (II) • How It Works • A: set of Euclidean coordinates corresponding to the input binary image • B: set of coordinates for the structuring element • Bx: translation of B so that its origin is at x. • The dilation of A by B is simply the set of all points x such that the intersection of Bx with A is non-empty.
Dilation in 1D is defined as : • A + B = {x : (Ḃ)x (intersection) A ≠ Ф} = ÜxЄB Ax (1) • Where A and B are sets in Z. this definition is also known as ‘MinkowskiAddition’. This equation simply means that B is moved over A and the intersection of B reflected and translated with A is found. Usually A will be the signal or image being operated on and B will be the Structuring Element’.
. The followingfigure shows how dilation works on a 1D binary signal. • The output is given by (1) and will be set to one unless the input is the inverse of the structuring element. For example, in the input it is ‘000’ would cause the output to be zero, if in the SE it ‘111’.
. Dilation has several interesting properties, which make it useful for image processing. These properties are: • Translation invariant. This means that the result of A dilated with B translated is the same as A translated dilated with B as given by: (A + B)x = Ax + B (2) • Order invariant This simply means that if several dilations are to be done, then the order in which they are done is irrelevant. The result will be same irrespective. (A + B) + C = A + (B + C) (3)
Increasing operator This means that if a set A, is a subject of another set B, then the dilation of A by C is still a subset of B dilated by C: (A contained in B) =› A + C contained in B + C (4) • Scale invariant This means that the input and structuring element can be scaled, then dilated and will give the same as scaling the dilated output: rA + rB = r(A + B) (5) Where r is a scale factor. These properties can be very useful in image processing and can result in some operations being simplified.
Effect of dilation using a 3×3 square structuring element Set of coordinate points = { (-1, -1), (0, -1), (1, -1), (-1, 0), (0, 0), (1, 0), (-1, 1), (0, 1), (1, 1) } 3×3 square structuring element Dilation (III) • Guideline for Use
Dilation (IV) • Example: Binary dilation • Note that the corners have been rounded off. • When dilating by a disk shaped structuring element, convex boundaries will become rounded, and concave boundaries will be preserved as they are. Result of two Dilation passes using a disk shaped structuring element of 11 pixels radius Original image Thresholded image
Result of dilation Original image Edge detection Dilation (V) • Example: Binary dilation (edge detection) • Dilation can also be used for edge detection by taking the dilation of an image and then subtracting away the original image.
Original image Region filling Dilation (VI) • Example: Binary dilation (Region Filling) • Dilation is also used as the basis for many other mathematical morphology operators, often in combination with some logical operators.
Dilation (VII) • Conditional dilation • Combination of the dilation operator and a logical operator • Region filling applies logical NOT, logical AND and dilation iteratively.
Dilation (VIII) X0 One pixel which lies inside the region Dilate the left image AND Step 1 Result Original image Negative of the boundary
Dilation (IX) X1 Dilate the left image AND Step 2 Result Negative of the boundary
Dilation (X) • Repeating dilation and with the inverted boundary until convergence, yields Step 4 Result Step 5 Result Step 6 Result Step 3 Result OR Final Result Original image Result of Region Filling
Dilation (XI) • Grayscale Dilation • Generally brighten the image • Bright regions surrounded by dark regions grow in size, and dark regions surrounded by bright regions shrink in size. • The effect of dilation using a disk shaped structuring element
Dilation (XII) • Example: Grayscale dilation (brighten the image) • The highlights on the bulb surface have increased in size. • The dark body of the cube has shrunk in size since it is darker than its surroundings. Original image Two passes Dilation by 3×3 flat square structuring element Five passes Dilation by 3×3 flat square structuring element
Dilation (XIII) Pepper noise image Dilation by 3×3 flat square structuring element
Morphological Erosion Structuring Element Pablo Picasso, Pass with the Cape, 1960
Erosion (I) • Brief Description • Erosion is one of the basic operators in the area of mathematical morphology. • Basic effect • Erode away the boundaries of regions of foreground pixels (i.e. white pixels, typically). Common names: Erode, Shrink, Reduce
Erosion (II) • How It Works • A: set of Euclidean coordinates corresponding to input binary image • B : set of coordinates for the structuring element • Bx: translation of B so that its origin is at x • The erosion of A by B is simply the set of all points x such that Bx is a subset of A
The Opposite of Dilation is known as Erosion • This is defined as: A Ө B = {x : (B)x contained in A} = ΠxЄB Ax (6) • This definition is also known as ‘Minkowski Substration’. The equation simply says, erosion of A by B is the set of points x such that B translated by x is contained in A. The following Figure shows how erosion works on a 1D binary signal. This works in exactly the same way as dilation. However (6) essentially says that for the output to be a one, all of the inputs must be the same as the structuring element.
Erosion, like dilation also contains properties that are useful for image processing: • Translation invariant. This means that the result of A eroded with B translated is the same as A translated eroded with B as given by: (A Ө B)x = Ax Ө B (7) • Order invariant This simply means that if several erosions are to be done, then the order in which they are done is irrelevant. The result will be same irrespective. (A Ө B) Ө C = A Ө (B Ө C) (8)
Increasing operator This means that if a set, A, is a subject of another set, B, then the erosion of A by C is still a subset of B eroded by C: (A Ө B) Ө C = A Ө C contained in B Ө C (9) • Scale invariant This means that the input and structuring element can eb scaled, then eroded and will give the same as scaling the eroded output: rA Ө rB = r(A Ө B) (10) Where r is a scale factor.
Set of coordinate points = { (-1, -1), (0, -1), (1, -1), (-1, 0), (0, 0), (1, 0), (-1, 1), (0, 1), (1, 1) } A 3×3 square structuring element Erosion (III) • Guideline for Use Effect of erosion using a 3×3 square structuring element
Erosion (IV) • Example: Binary erosion • It shows that the hole in the middle of the image increases in size as the border shrinks. • Erosion using a disk shaped structuring element will tend to round concave boundaries, but will preserve the shape of convex boundaries. Original thresholded image Result of erosion four times with a disk shaped structuring element of 11 pixels in diameter
Erosion (V) • Example: Binary erosion (separate touching objects) Original image (a number of dark disks) Inverted image after thresholding The result of eroding twice using a disk shaped structuring element 11 pixels in diameter Using 9×9 square structuring element leads to distortion of the shapes
Erosion (VI) • Grayscale erosion • Generally darken the image • Bright regions surrounded by dark regions shrink in size, and dark regions surrounded by bright regions grow in size. • The effect of erosion using a disk shaped structuring element
Erosion (VII) • Example: Grayscale erosion (darken the image) • The highlights have disappeared. • The body of the cube has grown in size since it is darker than its surroundings. Two passes Erosion by 3×3 flat square structuring element Five passes Erosion by 3×3 flat square structuring element Original image
Erosion (VIII) • Example: Grayscale erosion (Remove salt noise) • The noise has been removed. • The rest of the image has been degraded significantly. Erosion by 3×3 flat square structuring element Salt noise image
Opening (I) • Brief Description • The Basic Effect • Somewhat like erosion in that it tends to remove some of the foreground(bright) pixels from the edges of regions of foreground pixels. • To preserve foreground regions that have a similar shape to structuring element.
Opening (II) • How It works • Opening is defined as an erosion followed by a dilation. • Gray-level opening consists simply of a gray-level erosion followed by a gray-level dilation. • Opening is the dual of closing. • Opening the foreground pixels with a particular structuring element is equivalent to closing the background pixels with the same element.
Both dilation and erosion have interesting and useful properties. However, it would be useful to have the properties of both in one function. This can be done in two ways. The first method, ‘Opening’ is defined as: A ๐ B = (A Ө B) + B (11) • This simply erodes the signal and then dilates the result as shown in Figure 3. As can be seen, the zeros are opened up. Any ones that are shorter than the structuring element are removed, but the rest of the signal is left unchanged. • This is a very useful property as it means that if the filter is applied once, no more changes to the signal will result from repeated applications is known as Idempotent: (A ๐ B) ๐ B = A ๐ B (12)
Opening (III) • Guidelines for Use • Idempotence • After the opening has been carried out, the new boundaries of foreground regions will all be such that the structuring element fits inside them. • So further openings with the same element have no effect • Effect of opening using a 3×3 square structuring element
Opening (IV) • Binary Opening Example • Separate out the circles from the lines • The lines have been almost completely removed while the circles remain almost completely unaffected. Opening with a disk shaped structuring element with 11 pixels in diameter A mixture of circle and lines