필터 지우기
필터 지우기

How to take mean for watershed algorithm?

조회 수: 1 (최근 30일)
john
john 2012년 2월 7일
I applied watershed algorithm successfully.But I don't know how to take the mean of the result after applying that algorithm.

답변 (1개)

Sven
Sven 2012년 2월 7일
Hi John,
Step 1: Take your watershed (I'm just copying an example from the MATLAB docs, you will obviously have your own image I, and watershed L variables):
rgb = imread('pears.png' );
I = rgb2gray(rgb);
hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(I), hy, 'replicate');
Ix = imfilter(double(I), hx, 'replicate');
gradmag = sqrt(Ix.^2 + Iy.^2);
se = strel('disk', 20);
Io = imopen(I, se);
Ie = imerode(I, se);
Iobr = imreconstruct(Ie, I);
Ioc = imclose(Io, se);
Iobrd = imdilate(Iobr, se);
Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));
Iobrcbr = imcomplement(Iobrcbr);
fgm = imregionalmax(Iobrcbr);
se2 = strel(ones(5,5));
fgm2 = imclose(fgm, se2);
fgm3 = imerode(fgm2, se2);
fgm4 = bwareaopen(fgm3, 20);
bw = im2bw(Iobrcbr, graythresh(Iobrcbr));
D = bwdist(bw);
DL = watershed(D);
bgm = DL == 0;
gradmag2 = imimposemin(gradmag, bgm | fgm4);
L = watershed(gradmag2);
Step 2: take the mean pixel value of of each region using regionprops:
stats = regionprops(L,I,'MeanIntensity')
Does that answer your question?

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by