数字图像的边界提取

Posted OIqng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数字图像的边界提取相关的知识,希望对你有一定的参考价值。

对于图像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])

在这里插入图片描述

以上是关于数字图像的边界提取的主要内容,如果未能解决你的问题,请参考以下文章

数字图像处理-图像形态学处理-颗粒提取

matlab 提取图像轮廓(图像边缘提取)

图像形态学提取边界和区域填充

从深度图中提取物体边界

数字图像处理图像边缘锐化之微分运算

带有opencv的手写数字边界框