This document provides an overview of mathematical morphology concepts and operations for binary images. It introduces morphological operations like dilation, erosion, opening, and closing that can be used to modify image shapes and sizes. Dilation expands objects while erosion shrinks them. Opening and closing combine these to smooth contours or fill small holes. Structuring elements are used to specify the shape of these operations. The document describes techniques like boundary detection, noise removal, region filling, and skeletonization that apply morphological operations. Example MATLAB code is provided to demonstrate the techniques.
This document provides an overview of mathematical morphology concepts and operations for binary images. It introduces morphological operations like dilation, erosion, opening, and closing that can be used to modify image shapes and sizes. Dilation expands objects while erosion shrinks them. Opening and closing combine these to smooth contours or fill small holes. Structuring elements are used to specify the shape of these operations. The document describes techniques like boundary detection, noise removal, region filling, and skeletonization that apply morphological operations. Example MATLAB code is provided to demonstrate the techniques.
This document provides an overview of mathematical morphology concepts and operations for binary images. It introduces morphological operations like dilation, erosion, opening, and closing that can be used to modify image shapes and sizes. Dilation expands objects while erosion shrinks them. Opening and closing combine these to smooth contours or fill small holes. Structuring elements are used to specify the shape of these operations. The document describes techniques like boundary detection, noise removal, region filling, and skeletonization that apply morphological operations. Example MATLAB code is provided to demonstrate the techniques.
This document provides an overview of mathematical morphology concepts and operations for binary images. It introduces morphological operations like dilation, erosion, opening, and closing that can be used to modify image shapes and sizes. Dilation expands objects while erosion shrinks them. Opening and closing combine these to smooth contours or fill small holes. Structuring elements are used to specify the shape of these operations. The document describes techniques like boundary detection, noise removal, region filling, and skeletonization that apply morphological operations. Example MATLAB code is provided to demonstrate the techniques.
7SDN 7SDN LA8DFATDFY LA8DFATDFY Introduction to Image Processing Lecture Set 10 Chapter 10: Mathematical Morphology
H.Y.LIn, CCUEE ntroductIon to mage ProcessIng
Binary Image Morphology The word morphology refers to form and structure In image processing and computer vision, it can be used to refer to the shape of a region The operations of mathematical morphology were originally defined as set operations Morphological operators can: Thin, Thicken, Find boundaries, Find skeletons (medical axis), Convex hull, And more H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Structuring Llements The operations of binary morphology input a binary image B and a structuring element S The structuring element S is usually another smaller binary image It represents a shape It can be any size and have arbitrary structure that can be represented by a binary image Some common structuring elements 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Point Sets and Notation Binary objects are considered as point sets For point sets A and B denote the: Translation of A by x as A x = {a i + x | a i A} Figure 10.1, page 262, textbook Reflection of B as B r = {-b i | b i B} Figure 10.2, page 262, textbook Complement of A as A c = {a i | a i A} Example ? Difference of A and B as A B = {c i | (c i A) XOR (c i B)} Example ? H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Basic Operations The basic operations of binary morphology are dilation, erosion, closing, and opening Dilation enlarges a region Erosion makes a region smaller A closing operation can close up internal holes in a region and eliminate bays along the boundary An opening operation can get rid of small portions of the region that just out from the boundary into the background region Some applications Binary morphology can be used to extract primitive features of an object that can be used to recognize the object A shape matching system can use morphological feature detection to rapidly detect primitives that are used in object recognition H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Dilation Dilation of B by structuring element S: B S = {x i | (S x r B) )} = bB S b Example: dilating A with a 33 structuring element B centered at the origin Example: Figure 10.3, page 264, textbook B S H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Lxample - MA1LAB, p265.m t = imread('text.tif'); sq = ones(3,3); td = imdilate(t,sq); subplot(1,2,1),imshow(t) subplot(1,2,2),imshow(td) H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Lrosion Erosion of B by structuring element S: B S = {x i | S x B} = {b | b + s B, s S} Example: eroding A with a 33 structuring element B centered at the origin Example: Figure 10.6, page 267, textbook B S H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Lxample - MA1LAB, p266.m c = imread('circbw.tif'); ce = imerode(c,sq); subplot(1,2,1),imshow(c) subplot(1,2,2),imshow(ce) H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Announcements - 5,3,06 See some demos H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Application - Boundary Detection boundary(B,S) = B B S External boundary: (B S) B Morphological gradient: (B S) (B S) Example : Figure 10.9, page 270, textbook S erosion difference boundary(B,S) B H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Lxample - MA1LAB, p21.m rice = imread('rice.tif'); r = rice > 110; re = imerode(r,sq); r_int = r&~re; subplot(1,2,1),imshow(r) subplot(1,2,2),imshow(r_int) rd = imdilate(r,sq); r_ext = rd&~r; r_grad = rd&~re; figure subplot(1,2,1),imshow(r_ext) subplot(1,2,2),imshow(r_grad) H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Combining Dilation and Lrosion Combining dilation and erosion for Opening Closing Thickening Thinning Skeleton H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Intuitie Interpretation Dilation expands an object Erosion contracts an object Opening Smoothes contours Enlarges narrow gaps Eliminates thin protrusions Closing Fills narrow gaps, holes and small breaks H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Opening Opening: Like smoothing from the inside B S = (B S) S = {S x | S x B} Example: Figure 10.12, page 273, textbook S erosion dilation open(B,S) B H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Closing Closing: Like smoothing from the outside B S = (B S) S Example: Figure 10.13, page 274, textbook S dilation erosion close(B,S) B H.Y.LIn, CCUEE ntroductIon to mage ProcessIng More Lxample Dilation Erosion Opening Closing H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Idempotency Applying opening or closing more than once has no further effect open(open(A,B),B) = open(A,B) close(close(A,B),B) = close(A,B) H.Y.LIn, CCUEE ntroductIon to mage ProcessIng MA1LAB - p24.m sq = ones(3,3); cr = [0 1 0; 1 1 1; 0 1 0]; test = zeros(10,10); test(2:6,2:4) = 1; test(3:5,6:9) = 1; test(8:9,4:8) = 1; test(4,5) = 1 imopen(test,sq) imopen(test,cr) imclose(test,sq) imclose(test,cr) t = imread('text.tif') diag=[0 0 1; 0 1 0; 0 0 1] tc = imclose(t,diag); imshow(tc) H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Application - Noise Remoal Morphological filtering (page 276, textbook) ((A B) B) = (((A B) B) B) B Erosion, dilation, dilation, erosion H.Y.LIn, CCUEE ntroductIon to mage ProcessIng MA1LAB - p2.m c = imread('circles.tif'); x = rand(size(c)); d1 = find(x<=0.05); d2 = find(x>=0.95); c(d1) = 0; c(d2) = 1; imshow(c) cf1 = imclose(imopen(c,sq),sq); figure, imshow(cf1) cf2 = imclose(imopen(c,cr),cr); figure, imshow(cf2) H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Additional Structuring Operations Find boundary of an object Region filling Connected component (More on next chapter) Skeletonization (More on next chapter) H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Region lilling Problem: Fill 8-connected boundary A with 1s given a point inside the boundary p Use structuring element S, and Iterative dilations Complement Intersection S B p H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Region lilling Let C 0 = p Calculate C k = (C k-1 S) B c , for k = 1,2, Stop when C k = C k-1 C k is the interior of B Example: Figures 10.21, 10.22, pages 280, 281, textbook S B p H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Region lilling - MA1LAB function out=regfill(im,pos,kernel) % REGFILL(IM,POS,KERNEL) performs region filling of binary image IMAGE, % with kernel KERNEL, starting at point with coordinates given by POS. % % Example: % n=imread('nicework.tif'); % nb=n&~imerode(n,ones(3,3)); % nr=regfill(nb,[74,52],ones(3,3)); % current=zeros(size(im)); last=zeros(size(im)); last(pos(1),pos(2))=1; current=imdilate(last,kernel)&~im; while any(current(:)~=last(:)), last=current; current=imdilate(last,kernel)&~im; end; out=current; H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Region lilling - p.283.m n = imread('nicework.tif'); imshow(n), pixval on figure, imshow(n) nb = n &~imerode(n,sq); figure, imshow(nb) nf = regfill(nb,[74,52],sq); figure, imshow(nf) figure, imshow(nf|nb) H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Connected Component - p.283.m sq2 = ones(11,11); nc = components(n,[57,97],sq); figure, imshow(nc) nc2 = components(n,[57,97],sq2); figure,imshow(nc2) H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Skeletonization The skeleton of a binary object is a collection of lines and curves that encapsulate the size and shape of the object Lantuejouls method Table 10.1, Figure 10.28, page 285, textook Figure 10.29, page 286, textbook H.Y.LIn, CCUEE ntroductIon to mage ProcessIng Lantejoul`s Implementation function skel = imskel(image,str) % IMSKEL(IMAGE,STR) - Calculates the skeleton % of binary image IMAGE using % structuring element STR. This function uses % Lantejoul's algorithm. % skel=zeros(size(image)); e=image; while (any(e(:))), o=imopen(e,str); skel=skel | (e&~o); e=imerode(e,str); end H.Y.LIn, CCUEE ntroductIon to mage ProcessIng MA1LAB - p286.m sq = ones(3,3); cr = [0 1 0; 1 1 1; 0 1 0]; n = imread('nicework.tif'); nk = imskel(n,sq); imshow(nk) nk2 = imskel(n,cr); figure, imshow(nk2)