Marker controlled watershed segmentation

22 visualizaciones (últimos 30 días)
fary
fary el 13 de Dic. de 2017
Editada: Image Analyst el 13 de Dic. de 2017
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 comentario
Image Analyst
Image Analyst el 13 de Dic. de 2017
You forgot to attach one or more of your images.

Iniciar sesión para comentar.

Respuestas (2)

fary
fary el 13 de Dic. de 2017
I have attached two of the sample images above: color 'matrix.png' and label 'matrix.png'
  1 comentario
Image Analyst
Image Analyst el 13 de Dic. de 2017
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?

Iniciar sesión para comentar.


fary
fary el 13 de Dic. de 2017
I used a=imread(filename); to call the image depending on the one i select from my folder, and below are the original images i used.
  1 comentario
Image Analyst
Image Analyst el 13 de Dic. de 2017
Editada: Image Analyst el 13 de Dic. de 2017
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.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by