当前位置 博文首页 > OIqng的博客:数字图像的边界提取

    OIqng的博客:数字图像的边界提取

    作者:[db:作者] 时间:2021-07-14 10:05

    对于图像text.png,testpat1.png,coins.png用上面提到的六种方法分别提取边界并加以比较,对这三幅图像提取边界的结果,分别对每一幅图给出你的判断,认为哪种算子提取的边界最好?同时理解各种边界提取算子同时存在的必要性。对每一幅图均标出图题,并使图题的位置位于图的下方,居中,选择其中的一幅图,使其图题的字体为黑体,字号为14号。
    text.pngtestpat1.png
     coins.png

    imname='text.png'
    I=imread(imname);
    BW1=edge(I,'sobel');
    BW2=edge(I,'prewitt');
    BW3=edge(I,'roberts');
    BW4=edge(I,'log');
    BW5=edge(I,'zerocross');
    BW6=edge(I,'canny');
    imshow(I);
    text=strcat('图1:',imname,'原图')
    title(text,'fontsize',14,'fontname','黑体','position',[128,280,0]);
    figure;imshow(BW1);
    title('图2:sobel算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW2);
    title('图3:prewitt算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW3);
    title('图4:roberts算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW4);
    title('图5:log算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW5);
    title('图6:zerocross算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW6);
    title('图7:canny算子提取的边界','fontsize',14,'position',[128,280,0])
    

    在这里插入图片描述

    imname='testpat1.png'
    I=imread(imname);
    BW1=edge(I,'sobel');
    BW2=edge(I,'prewitt');
    BW3=edge(I,'roberts');
    BW4=edge(I,'log');
    BW5=edge(I,'zerocross');
    BW6=edge(I,'canny');
    imshow(I);
    text=strcat('图1:',imname,'原图')
    title(text,'fontsize',14,'fontname','黑体','position',[128,280,0]);
    figure;imshow(BW1);
    title('图2:sobel算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW2);
    title('图3:prewitt算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW3);
    title('图4:roberts算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW4);
    title('图5:log算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW5);
    title('图6:zerocross算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW6);
    title('图7:canny算子提取的边界','fontsize',14,'position',[128,280,0])
    

    在这里插入图片描述

    imname='coins.png'
    I=imread(imname);
    BW1=edge(I,'sobel');
    BW2=edge(I,'prewitt');
    BW3=edge(I,'roberts');
    BW4=edge(I,'log');
    BW5=edge(I,'zerocross');
    BW6=edge(I,'canny');
    imshow(I);
    text=strcat('图1:',imname,'原图')
    title(text,'fontsize',14,'fontname','黑体','position',[128,280,0]);
    figure;imshow(BW1);
    title('图2:sobel算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW2);
    title('图3:prewitt算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW3);
    title('图4:roberts算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW4);
    title('图5:log算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW5);
    title('图6:zerocross算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW6);
    title('图7:canny算子提取的边界','fontsize',14,'position',[128,280,0])
    

    在这里插入图片描述
    对于图像tire.tif,通过调整阈值的方法,得出一幅你认为较好的边界图,并给出此时的阈值。

    tire.tif

    I=imread('tire.tif');
    [BW1,th1]=edge(I,'canny',[0.05,0.2])
    th1str=num2str(th1);
    imshow(I);
    title('图1:rice.png原图','fontsize',14,'position',[128,280,0]);
    figure;
    imshow(BW1);
    ti='图8:sobel算子提取的边界,阈值为';
    ti=strcat(ti,th1str);title(ti,'fontsize',12,'position',[128,280,0])
    

    在这里插入图片描述
    对于图像snowflakes.png用上面提到的六种方法分别提取边界并加以比较,这次你认为那种算子提取的边界最好?

    在这里插入图片描述

    imname='snowflakes.png'
    I=imread(imname);
    BW1=edge(I,'sobel');
    BW2=edge(I,'prewitt');
    BW3=edge(I,'roberts');
    BW4=edge(I,'log');
    BW5=edge(I,'zerocross');
    BW6=edge(I,'canny');
    imshow(I);
    text=strcat('图1:',imname,'原图')
    title(text,'fontsize',14,'fontname','黑体','position',[128,280,0]);
    figure;imshow(BW1);
    title('图2:sobel算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW2);
    title('图3:prewitt算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW3);
    title('图4:roberts算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW4);
    title('图5:log算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW5);
    title('图6:zerocross算子提取的边界','fontsize',14,'position',[128,280,0])
    figure;imshow(BW6);
    title('图7:canny算子提取的边界','fontsize',14,'position',[128,280,0])
    

    在这里插入图片描述

    cs
    下一篇:没有了