数字图像处理 图像分割(部分)

编程入门 行业动态 更新时间:2024-10-27 14:23:39

数字<a href=https://www.elefans.com/category/jswz/34/1769353.html style=图像处理 图像分割(部分)"/>

数字图像处理 图像分割(部分)

    • 图像分割
      • 点,线和边缘检测 
        • 点检测
        • 线检测
        •  使用edge函数的边缘检测
    • 使用Hough变换的线检测
    • 阈值处理
      • 全局阈值处理

图像分割

点,线和边缘检测 

点检测
>> w = [-1 -1 -1; -1 8 -1; -1 -1 -1];
>> f = imread('Fig1002(a)(test_pattern_with_single_pixel).tif');
>> g = abs(imfilter(double(f),w));
>> T = max(g(:));
>> g = g >= T;
>> imshow(f);figure,imshow(g);

(我看不清成果…)

线检测
>> w = [2 -1 -1; -1 2 -1;-1 -1 2];
>> f = imread('Fig1004(a)(wirebond_mask).tif');
>> imshow(f);
>> g = imfilter(double(f),w);
>> figure,imshow(g,[]);
>> gtop = g(1:120, 1:120);
>> gtop = pixeldup(gtop, 4);
>> figure,imshow(gtop,[]);
>> gbot = g(end-119:end, end-119:end);
>> gbot = pixeldup(gbot, 4);
>> figure,imshow(gbot,[]);
>> g = abs(g);
>> figure,imshow(g,[]);
>> T = max(g(:));
>> g = g >= T;
>> figure,imshow(g);

  1. 原图
  2. 使用-45°检测器处理后的结果
  3. 2图左上角的放大图
  4. 2图右下角的放大图
  5. 2图的绝对值
  6. 值满足 g >= T的所有点(白色)
 使用edge函数的边缘检测

使用Sobel检测器提取边缘

>> f = imread('Fig1006(a)(building).tif');
>> [gv, t] = edge(f,'sobel','vertical');
>> imshow(gv);
>> imshow(f);
>> figure,imshow(gv);
>> tt =0.0516>> gv = edge(f,'sobel',0.15,'vertical');
>> figure,imshow(gv);
>> gboth = edge(f,'sobel',0.15);
>> figure,imshow(gv);

  1. 原图
  2. 使用带有自动确定的阈值的一个垂直Sobel掩模后,函数edge导致的结果
  3. 使用指定阈值后的结果
  4. 使用指定阈值来决定绘制边缘和水平边缘的结果

使用Hough变换的线检测

从稀疏矩阵S获得完整矩阵用函数full:

A = full(s);

Hough 变换的说明

用一幅简单的二值图像来说明hough函数的用法

>> f = zeros(101,101);
>> f(1,1) = 1;f(101,1)=1;f(1,101) = 1;
>> f(101,101)=1;f(51,51)=1;
>> imshow(f);
>> H = hough(f);
>> imshow(H,[]);
>> imshow(f);
>> figure,imshow(H,[]);
>> [H, theta, rho] = hough(f);
>> imshow(H, [], 'XData', theta, 'YData', rho, 'InitialMagnification', 'fit');
>> axis on, axis normal
>> xlabel('\theta'), ylabel('\rho')

(用了书上的方法会报错,

>> imshow(theta ,rho, H, [], 'notruesize');
错误使用 images.internal.imageDisplayParsePVPairs (line 71)
imageDisplayParsePVPairs 无法识别参数 notruesize出错 images.internal.imageDisplayParseInputs (line 69)
[common_args,specific_args] = images.internal.imageDisplayParsePVPairs(varargin{:});出错 imshow (line 241)images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});

很难受)

  1. 原图
  2. hough变换后
  3. 带有标度轴的hough变换

阈值处理

全局阈值处理

>> f = imread('Fig1013(a)(scanned-text-grayscale).tif');
>> T = 0.5*(double(min(f(:))) + double(max(f(:))));
>> done = false;
>> while ~done
g = f >= T;
Tnext = 0.5*(mean(f(g)) + mean(f(~g)))
done = abs(T - Tnext) < 0.5;
T = Tnext;
endTnext =98.5539Tnext =100.4909Tnext =101.1440Tnext =101.4717>> imshow(f);figure,imshow(g);

用T处理经行阈值处理的结果

更多推荐

数字图像处理 图像分割(部分)

本文发布于:2024-02-12 06:53:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1686686.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像处理   图像   数字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!