Marker controlled watershed segmentation
显示 更早的评论
Please i am using the above algorithm for the segmentation of red blood cell in an image but its not as clear as i want it to be, can someone please help me check where the problem is coming from? below is the code and attached is the output am having.
filename = uigetfile({'*.jpg;*.jpeg;*.tif.;*.png;*.gif','All Image Files';... '*.*','All Files' },'mytitle',... 'C:\Work\setpos1.png')
global a; a=imread(filename); a=imresize(a,[500 500]); figure, imshow(a); title('Orginal Image'); a=im2double(a); fs=fspecial('average');
Red1=a(:,:,1); Red1=medfilt2(Red1); Red1=imfilter(Red1,fs,'replicate'); figure imshow(Red1);
Green1=a(:,:,2); Green1=medfilt2(Green1); Green1=imfilter(Green1,fs,'replicate'); figure imshow(Green1);
Blue1=a(:,:,3); Blue1=medfilt2(Blue1); Blue1=imfilter(Blue1,fs,'replicate'); figure imshow(Blue1);
Blue1=adapthisteq(Blue1); figure, imshow(Blue1); title('Histogram Equilized');
hy = fspecial('sobel'); hx = hy'; Iy = imfilter(double(Blue1), hy, 'replicate'); Ix = imfilter(double(Blue1), hx, 'replicate'); gradmag = sqrt(Ix.^2 + Iy.^2); figure, imshow(gradmag,[]), title('Gradient magnitude (gradmag)')
L = watershed(gradmag); Lblgr = label2rgb(L); figure, imshow(Lblgr), title('Watershed transform of gradient magnitude (Lblgr)')
se = strel('disk', 5); Io = imopen(Blue1, se); figure, imshow(Io), title('Opening (Io)')
Ie = imerode(Blue1, se); Iobr = imreconstruct(Ie, Blue1); figure, imshow(Iobr), title('Opening-by-reconstruction (Iobr)')
Ioc = imclose(Io, se); figure, imshow(Ioc), title('Opening-closing (Ioc)')
Iobrd = imdilate(Iobr, se); Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr)); figure, imshow(Iobrcbr), title('Opening-closing by reconstruction (Iobrcbr)')
fgm = imregionalmax(Iobrcbr); figure, imshow(fgm), title('Regional maxima of opening-closing by reconstruction (fgm)')
I2 = Blue1; I2(fgm) = 255; figure, imshow(I2), title('Regional maxima superimposed on original image (I2)')
se2 = strel(ones(6,6)); fgm2 = imclose(fgm, se2); fgm3 = imerode(fgm2, se2); fgm4 = bwareaopen(fgm3, 20); I3 = Blue1; I3(fgm4) = 255; figure, imshow(I3); title('Modified regional maxima superimposed on original image (fgm4)')
threshold = graythresh(Iobrcbr); bw=imbinarize(Iobrcbr,threshold); figure, imshow(bw), title('Thresholded opening-closing by reconstruction (bw)')
D = bwdist(bw); DL = watershed(D); bgm = DL==0; figure, imshow(bgm), title('Watershed ridge lines (bgm)')
gradmag2 = imimposemin(gradmag, bgm | fgm4); L = watershed(gradmag2); I4 = Blue1; I4(imdilate(L == 0, ones(3, 3)) | bgm | fgm4) = 255; figure, imshow(I4); title('Markers and object boundaries superimposed on original image (I4)')
Lblgr = label2rgb(L, 'jet', 'k', 'shuffle'); figure, imshow(Lblgr); title('Colored watershed label matrix (Lrgb)')
figure, imshow(Blue1) hold on himage = imshow(Lblgr); himage.AlphaData = 0.3; title('Lrgb superimposed transparently on original image')
1 个评论
Image Analyst
2017-12-13
You forgot to attach one or more of your images.
回答(2 个)
fary
2017-12-13
0 个投票
1 个评论
Image Analyst
2017-12-13
You attached two screenshots. Now, I'm sure you didn't call imread() on those screenshots did you? Why didn't you attach darkfield.jpg and brightfield.jpg????? Or whatever original RGB image you used?
fary
2017-12-13
1 个评论
Image Analyst
2017-12-13
编辑:Image Analyst
2017-12-13
Can you please edit your original question way up top and attach these images there, because you posted here as an official "Answer" to your original question, which it is not.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Segmentation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!