• 图像边缘检测


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

    二、实验内容: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算子进行边缘检测。
  • 相关阅读:
    迅雷的工作原理 [揭密迅雷]
    揭密迅雷BT式下载本质 [揭密迅雷]
    2010年8月09日_周一_Toc control
    2010年8月08日_周日_MapCopyrightText control
    2010年8月08日_周日_Magnifier control
    2010年8月07日_周六_HoverExpandExtender control
    2010年8月11日_周三_ZoomLevel_control
    ArcGIS Server网站发布后地图显示空白的原因之一
    2010年8月10日_周二_TaskManagercontrol
    搭建一个简单的callBack函数
  • 原文地址:https://www.cnblogs.com/henuliulei/p/10957227.html
Copyright © 2020-2023  润新知