What is the method of matlab morphological expansion and corrosion?
This article mainly introduces the relevant knowledge of "what is the method of matlab morphological expansion and corrosion". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "what is the method of matlab morphological expansion and corrosion" can help you solve the problem.
% enlarge the image to enlarge the shape
Use the imdilate function to extend the image
% morphological expansion operation expands or thickens foreground objects in an image
BW = zeros (9, 10)
BW (4JV 6pm 4R 7) = 1
Imshow (imresize (BW,40,'nearest'))
Create a structural element to use with imdilate
To expand a geometric object, you usually need to create a structural element that has the same shape as the object
SE = strel ('square',3)
Pass input images and structural elements to imdilate
Add 1 to all edges of the foreground object
BW2 = imdilate (BW,SE)
Imshow (imresize (BW2,40,'nearest'))
For comparison, create a structural element of a different shape
Expand the original image with new structural elements
SE2 = strel ('diamond',1)
BW3 = imdilate (BW,SE2)
Imshow (imresize (BW3,40,'nearest'))
Montage ({BW,BW2,BW3}, 'Size', [3 1])
%% corrodes the image to remove fine lines
% use the imerode function to corrupt the binary image
% image read and display image
BW1 = imread ('circbw.tif')
Imshow (BW1)
Create a diagonal structure element
SE = strel ('arbitrary',eye (7))
% corrosion image
BW2 = imerode (BW1,SE)
% display original image and corrosion image
The diagonal stripe is due to the shape of the structural element.
Imshow (BW2)
Montage ({BW1,BW2}, 'Size', [2 1])
This is the end of the content about "what is the method of matlab morphological expansion and corrosion". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.