Please explain the following code

조회 수: 1 (최근 30일)
Sahil khandelwal
Sahil khandelwal 2022년 5월 21일
답변: Image Analyst 2022년 5월 21일
%% watershed segmentation
hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(sout), hy, 'replicate');
Ix = imfilter(double(sout), hx, 'replicate');
gradmag = sqrt(Ix.^2 + Iy.^2);
L = watershed(gradmag);
Lrgb = label2rgb(L);
axes(handles.axes3);
imshow(Lrgb);

답변 (1개)

Image Analyst
Image Analyst 2022년 5월 21일
You just need to add comments, which you could have done after reading the documentation for each function.
% Watershed segmentation
% Get the Sobel edge filter convolution kernel for one direction.
hy = fspecial('sobel');
% Get the Sobel edge filter convolution kernel for the other direction.
hx = hy';
% Get the vertical edges.
Iy = imfilter(double(sout), hy, 'replicate');
% Get the horizontal edges.
Ix = imfilter(double(sout), hx, 'replicate');
% Combine the edges to get the edges all around the objects.
gradmag = sqrt(Ix.^2 + Iy.^2);
% Evidently for this (missing) image the edges should be split apart into
% different blobs.
L = watershed(gradmag);
% Create an image where each separated blob has a different color.
Lrgb = label2rgb(L);
% Display that colorized image of the distinct blobs.
axes(handles.axes3);
imshow(Lrgb);

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by