I want to extract area of segmented regions
rgb = imread('outdscene.jpg'); 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); I2 = I; I2(fgm) = 255;%clean the edges of the marker blobs
se2 = strel(ones(5,5)); fgm2 = imclose(fgm, se2); fgm3 = imerode(fgm2, se2); fgm4 = bwareaopen(fgm3,20); I3 = I; I3(fgm4) = 255; bw = im2bw(Iobrcbr, graythresh(Iobrcbr)); D = bwdist(bw); DL = watershed(D); bgm = DL == 0;%Compute the Watershed Transform of the Segmentation Function
gradmag2 = imimposemin(gradmag, bgm | fgm4); L = watershed(gradmag2); I4 = I; I4(imdilate(L == 0, ones(3,3)) | bgm | fgm4) = 255; Lrgb = label2rgb(L, 'jet', 'w', 'shuffle'); figure, imshow(Lrgb) title('Colored watershed label matrix (Lrgb)');
% Please, i want to know how can i extract regions area from this label matrix
Best Answer