Download presentation
Presentation is loading. Please wait.
Published byGrant Stafford Modified over 8 years ago
1
Morphology Image Processing Lab 6
2
Dilationgrow image regions Erosionshrink image regions Openingremoval of image region Closingfilling in image region Thickeningthickens objects by adding pixels to the exterior of objects. ThinningOpposite of thicken Skeletonizationremoves pixels on the boundaries of objects but does not allow objects to break apart. The pixels remaining make up the image skeleton.
3
Dilation & Erosion DilationErosion Operation that “grows” or “expand” objects in an image. Operation that “shrinks” or “reduce” objects in an image. D = imdilate(image, structuring element);E = imerode(image, structuring element); Both are controlled by a shape referred to as a structuring element. The image could be binary(black&white) OR intensity(grayscale) image
4
Function strel Create morphological structuring element (STREL), with a variety of shapes and sizes. se = strel(shape,parameters);
5
SyntaxDescription SE = strel('diamond',R)R specifies the distance from the structuring element origin to the points of the diamond. SE = strel('disk',R)R specifies the radius. SE = strel('line',LEN,DEG)LEN specifies the length, and DEG specifies the angle (in degrees) of the line, as measured in a counterclockwise direction from the horizontal axis.
6
SyntaxDescription SE = strel('rectangle',[M,N])MN specifies the size. MN must be a two-element vector of nonnegative integers. The first element of MN is the number of rows in the structuring element neighborhood; the second element is the number of columns. SE = strel('square',W)width is W pixels. W must be a nonnegative integer scalar. SE = strel('octagon',R)R specifies the distance from the structuring element origin to the sides of the octagon, as measured along the horizontal and vertical axes.
7
imdilate example with binary >>bw = imread('text.png'); >>se = strel('line',11,90); >>bw2 = imdilate(bw,se); >>imshow(bw), title('Original'), figure, imshow(bw2), title('Dilated');
8
imdilate example with grayscale >>I = imread('cameraman.tif'); >>se = strel(‘rectangle',[5,5]); >>I2 = imdilate(I,se); >>imshow(I), title('Original'),figure, imshow(I2), title('Dilated');
9
imerode example with binary >>originalBW = imread('circles.png'); >>se = strel('disk',11); >>erodedBW = imerode(originalBW,se); >>imshow(originalBW), figure, imshow(erodedBW)
10
imerode example with grayscale >>I = imread('cameraman.tif'); >> se=strel('rectangle',[5,5]); >>I2 = imerode(I,se); >>imshow(I), title('Original'), figure, imshow(I2), title('Eroded‘);
11
imdilate, imerode Example >> BW = imread('circbw.tif'); >> se=strel('square',3); >> BWD = imdilate(BW,se); >> BWE = imerode(BW,se); >> imshow(BW),figure,imshow(BWD),figure,imshow(BWE);
12
Combining Dilation & Erosion The most common combinations of dilation and erosion: opening. closing. openingclosing Erosion Dilation Erodes an image and then dilates the eroded image using the same structuring element for both operations. Used for: removal of image region Dilation Erosion Dilates an image and then erodes the dilated image using the same structuring element for both operations. Used for: filling in image region OIM = imopen(image,structuring element)CIM = imclose(image, structuring element) Both are controlled by a shape referred to as a structuring element Image could be binary(black&white) OR intensity(grayscale) image
13
imopen Example This example uses imopen to filter out the smaller objects in an image. >> I = imread('snowflakes.png'); Create a disk-shaped structuring element with a radius of 5 pixels. >>se = strel('disk',5); Remove snowflakes having a radius less than 5 pixels by opening it with the disk-shaped structuring element. >> I_opened = imopen(I,se); >>Imshow(I), figure, imshow(I_opened,[]);
14
imclose example This example uses imclose to join the circles in the image together by filling in the gaps between them and by smoothening their outer edges. >>originalBW = imread('circles.png'); Create a disk-shaped structuring element. Use a disk structuring element to preserve the circular nature of the object. Specify a radius of 10 pixels so that the largest gap gets filled. >>se = strel('disk',10); >>closeBW = imclose(originalBW,se); >> imshow(originalBW),figure, imshow(closeBW);
15
Some morphological operations There are a variety of morphological operations based on combinations of dilations, erosions, and lookup table operations: Thickening. Thinning. Skeletonization. These operations can be accomplished by bwmorph function in matlab.
16
bwmorph g = bwmorph( i, operation, n) i the input image(should be black&white) operation string specifying the operation n number of times the operation should be repeated. If n is ommited n=1 If n = Inf repeat the operation until the image stops changing. (should used with ‘skel’) ‘thicken’ thickens objects by adding pixels to the exterior of objects. ‘thin’ opposit of thicken ‘skel’ removes pixels on the boundaries of objects but does not allow objects to break apart. The pixels remaining make up the image skeleton.
17
Examples BW1 = imread('circbw.tif'); BW2 = bwmorph(BW1,'skel',Inf); imshow(BW1),figure, imshow(BW2); BW = imread('circles.png'); BW2 = bwmorph(BW,'skel',Inf); imshow(BW),figure, imshow(BW2);
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.