• 图像边缘检测


    一、实验目的:熟悉边缘检测的基本方法

    二、实验内容:chairgray.jpg图像为例,分别采用sobelprewittroberts

    log对该图像及其加上噪声后的图像进行边缘检测。用到的matlab函数为edge,imnoise

     1 a=imread('D:/picture/ZiXia.jpg');
     2 a=rgb2gray(a);
     3 figure('name','图像分割');
     4 subplot(2,5,1)
     5 imshow(a);
     6 bw1=edge(a,'sobel');
     7 bw2=edge(a,'prewitt');
     8 bw3=edge(a,'roberts');
     9 bw4=edge(a,'log');
    10 subplot(2,5,2),imshow(bw1);
    11 xlabel('sobel');
    12 subplot(2,5,3),imshow(bw2);
    13 xlabel('prewitt');
    14 subplot(2,5,4),imshow(bw3);
    15 xlabel('roberts');
    16 subplot(2,5,5),imshow(bw4);
    17 xlabel('log');
    18 a=imnoise(a,'gaussian',0.02);
    19 subplot(2,5,6)
    20 imshow(a);
    21 bw1=edge(a,'sobel');
    22 bw2=edge(a,'prewitt');
    23 bw3=edge(a,'roberts');
    24 bw4=edge(a,'log');
    25 subplot(2,5,7),imshow(bw1);
    26 xlabel('sobel');
    27 subplot(2,5,8),imshow(bw2);
    28 xlabel('prewitt');
    29 subplot(2,5,9),imshow(bw3);
    30 xlabel('roberts');
    31 subplot(2,5,10),imshow(bw4);
    32 xlabel('log');

     

    可以得知噪声对边缘检测的结果会产生一定的影响

    edge函数介绍

    BW = edge(I)
    采用灰度或一个二值化图像I作为它的输入,并返回一个与I相同大小的二值化图像BW,在函数检测到边缘的地方为1,其他地方为0。
    
    BW = edge(I,'sobel') 自动选择阈值用Sobel算子进行边缘检测。
    
    BW = edge(I,'sobel',thresh) 根据所指定的敏感度阈值thresh,用Sobel算子进行边缘检测,它忽略了所有小于阈值的边缘。当thresh为空时,自动选择阈值。
    
    BW = edge(I,'sobel',thresh,direction) 根据所指定的敏感度阈值thresh,在所指定的方向direction上,用Sobel 算子进行边缘检测。Direction可取的字符串值为horizontal(水平方向)、vertical(垂直方向)或both(两个方向)。
    
    [BW,thresh] = edge(I,'sobel',...) 返回阈值
    
    BW = edge(I,'prewitt') 自动选择阈值用prewitt算子进行边缘检测。
    
    BW = edge(I,'prewitt',thresh) 根据所指定的敏感度阈值thresh,用prewitt算子进行边缘检测,它忽略了所有小于阈值的边缘。当thresh为空时,自动选择阈值。
    
    BW = edge(I,'prewitt',thresh,direction) 根据所指定的敏感度阈值thresh,在所指定的方向direction上,用prewitt算子进行边缘检测。Direction可取的字符串值为horizontal(水平方向)、vertical(垂直方向)或both(两个方向)默认方向为both。
    
    [BW,thresh] = edge(I,'prewitt',...) 返回阈值
    
    BW = edge(I,'roberts') 自动选择阈值用roberts算子进行边缘检测。
    
    BW = edge(I,'roberts',thresh) 根据所指定的敏感度阈值thresh,用Roberts算子进行边缘检测,它忽略了所有小于阈值的边缘。当thresh为空时,自动选择阈值。 Matlab中文论坛
    
    [BW,thresh] = edge(I,'roberts',...) 返回阈值
    
    BW = edge(I,'log') 自动选择阈值用LOG算子进行边缘检测。
  • 相关阅读:
    ural 1818 Fair Fishermen
    2013ACM-ICPC杭州赛区全国邀请赛总结
    成为程序界的叶问,你需要打败这十个人
    在互联网时代,你是消费者还是创造者?
    别让好想法埋没:如何进行APP开发?
    从无到有:学习程序开发的四个步骤
    BAT三家互联网公司哪家更注重用户体验?
    Stack Overflow大揭密:哪一种程序员工资最高?
    web产品浏览器兼容性问题你有考虑到吗?
    响应式网页设计:互联网web产品RWD概念
  • 原文地址:https://www.cnblogs.com/henuliulei/p/10957227.html
Copyright © 2020-2023  润新知