zoukankan      html  css  js  c++  java
  • 分水岭变换

    % Question No: 8
    % Consider a binary image composed of small blobs. Segmenting the circular
    % blobs using
    %   a) Distance Transform
    %   b) Watershed Transform
    
    function watersd(x)
    f=imread(x);
    bw=im2bw(f,graythresh(f));
    bwc=~bw;
    dst=bwdist(bwc);
    ws=watershed(-dst);
    w=ws==0;
    rf=bw&~w;
    figure,imshow(f),title('Original Image');
    figure,imshow(bw,[]),title('Negative Image');
    figure,imshow(ws,[]),title('Watershed - Distance Transform');
    figure,imshow(rf,[]),title('Superimposed - Watershed and original image');
    
    h=fspecial('sobel');
    fd=im2double(f);
    sq=sqrt(imfilter(fd,h,'replicate').^2+imfilter(fd,h','replicate').^2);
    sqoc=imclose(imopen(sq,ones(3,3)),ones(3,3));
    wsd=watershed(sqoc);
    wg=wsd==0;
    rfg=f;
    rfg(wg)=255;
    figure,imshow(wsd),title('Watershed - Gradient');
    figure,imshow(rf),title('Superimposed - Watershed and original image');
    
    im=imextendedmin(f,20);
    Lim=watershed(bwdist(im));
    figure,imshow(Lim),title('Watershed - Marker Controlled');
    em=Lim==0;
    rfmin=imimposemin(sq,im|em);
    wsdmin=watershed(rfmin);
    figure,imshow(rfmin),title('Watershed - Gradient and Marker Controlled');
    rfgm=f;
    rfgm(wsdmin==0)=255;
    figure,imshow(rfgm),title('Superimposed - Watershed (GM) and original image');
    end
    
    
    

  • 相关阅读:
    linux基础——虚拟机的创建及安装操作系统
    并发编程之多进程
    操作系统与进程(理论知识点)
    粘包
    socket-网络编程
    网络编程1
    网络编程
    异常
    元类
    反射与内置方法
  • 原文地址:https://www.cnblogs.com/xiangshancuizhu/p/1916903.html
Copyright © 2011-2022 走看看