130 likes | 331 Views
Morphological image processing. April 4, 2012. Example binary image B. Grayscale image f( x,y ). z = randn (100); z = conv2( z,ones (7),'same');. Z_BW=z>5; figure; imagesc (Z_BW). BW image filtered by convolution. figure; imagesc (conv2(double(Z_BW),ones(5),'same')).
E N D
Morphological image processing April 4, 2012
Example binary image B Grayscale image f(x,y) z =randn(100); z = conv2(z,ones(7),'same'); Z_BW=z>5; figure; imagesc(Z_BW)
BW image filtered by convolution figure; imagesc(conv2(double(Z_BW),ones(5),'same')) Image is smoothed but no longer binary (black and white)
>> strel ('disk', 5) >> strel ('square', 5) Neighborhood: 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 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 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 Neighborhood: 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 >> strel ('line', 5, 90) Neighborhood: 1 1 1 1 1 >> strel ('arbitrary', [0 0 1 0 0; 0 0 1 0 0; 1 1 1 1 1; 0 0 1 0 0; 0 0 1 0 0]) Neighborhood: 0 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 1 0 0 0 0 1 0 0 >> strel ('line', 5, 45) Neighborhood: 0 0 1 0 1 0 1 0 0
Erosion B A Binary Image Structuring element Image eroded with structuring element
Erosion B A Binary Image Structuring element Image eroded with structuring element
Dilation B A Binary Image Structuring element Image dilated with structuring element
imdilate(Z_BW,strel('disk',1)) Notice lone pixels take the shape of the structuring element
~imerode(Z_BW,strel('disk',1)) imdilate(~Z_BW,strel('disk',1))