watershed algorithm in matlab

前端 未结 2 1162
独厮守ぢ
独厮守ぢ 2020-12-15 11:36

anyone knows how to write a function in matlab to segment the cells and compute the average cell area using the watershed algorithm? any help would be much appreciated. Than

相关标签:
2条回答
  • 2020-12-15 12:14

    See watershed in the Image Processing toolbox and this post on cell segmentation on the 'Steve on Image Processing' blog.

    0 讨论(0)
  • 2020-12-15 12:33

    Here's one way to segment the image using watershed. There's plenty more you could do (e.g. fuse cells with two nuclei if they haven't completed cytokinesis yet), but the steps below should give you a first idea.

    (1) Determine cell-background threshold, cell-nucleus threshold

    %# read image
    img = imread('http://i.stack.imgur.com/nFDkX.png');
    %# normalize to 0...1
    imgN = double(img-min(img(:)))/(max(img(:)-min(img(:))));
    th1=graythresh(imgN);
    th2 = graythresh(imgN(imgN>th1));
    
    cellMsk = imgN>th1;
    nucMsk = imgN>th2;
    
    figure,imshow(cellMsk+nucMsk,[])
    

    enter image description here

    (2) Smooth the raw image (to avoid oversegmentation) and impose nuclei as minima

    [xx,yy]=ndgrid(-5:5,-5:5);
    gf = exp((-xx.^2-yy.^2)/20);
    filtImg = conv2(imgN,gf,'same');
    
    figure,imshow(filtImg,[])
    
    filtImgM = imimposemin(-filtImg,nucMsk);
    

    enter image description here

    (3) Watershed, mask cells, and display

    ws = watershed(filtImgM);
    ws(~cellMsk) = 0;
    
    lblImg = bwlabel(ws);
    
    figure,imshow(label2rgb(lblImg,'jet','k','shuffle'));
    

    enter image description here

    (4) Now you can use REGIONPROPS on the labeled image to extract the statistics you want.

    0 讨论(0)
提交回复
热议问题