第八章例题

本文档详细介绍了使用MATLAB进行图像处理和计算机视觉的多个例题,涵盖了从边界检测、区域属性计算到纹理分析和主成分应用等核心概念。包括bwboundaries和bound2im函数的使用,弗雷曼链码,区域骨骼计算,傅里叶描绘子,拐角检测,regionprops函数,纹理测度,共生矩阵,频谱纹理计算以及不变矩和主分量分析等实践应用。
摘要由CSDN通过智能技术生成

例8.1使用函数bwboundaries和bound2im.

clc,clear,close all;
f = [
 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
 0 1 1 1 1 1 1 1 1 1 1 1 1 0;
 0 1 1 1 1 1 1 1 1 1 1 1 1 0;
 0 1 1 0 0 0 0 0 0 0 0 1 1 0;
 0 1 1 0 1 1 1 1 1 1 0 1 1 0;
 0 1 1 0 1 1 1 1 1 1 0 1 1 0;
 0 1 1 0 1 1 0 0 1 1 0 1 1 0;
 0 1 1 0 1 1 0 0 1 1 0 1 1 0;
 0 1 1 0 1 1 1 1 1 1 0 1 1 0;
 0 1 1 0 1 1 1 1 1 1 0 1 1 0;
 0 1 1 0 0 0 0 0 0 0 0 1 1 0;
 0 1 1 1 1 1 1 1 1 1 1 1 1 0;
 0 1 1 1 1 1 1 1 1 1 1 1 1 0;
 0 0 0 0 0 0 0 0 0 0 0 0 0 0
];
B = bwboundaries(f, 'noholes');
numel(B)
b = cat(1, B{:});
[M, N] = size(f);
imgae = bound2im(b, M, N)
[B, L, NR, A] = bwboundaries(f);
numel(B)
numel(B) - NR
bR = cat(1, B{1:2}, B{4});
imageBoundaries = bound2im(bR, M, N);
imageNumveredBoundaries = imageBoundaries.*L
bR = cat(1, B{:});
imageBoundaries = bound2im(bR, M, N);
imageNumberedBoundaries = imageBoundaries.*L
find(A(:,1))
find(A(1,:))
A
full(A)

在这里插入图片描述

例8.2弗雷曼链码及其某些变化

clc,clear,close all;
f = imread('F:\qq\Digital-Image-Processing-main\Digital-Image-Processing-main\matlab教材示例图片\dipum_images_ch11\Fig1102(a)(noisy_circular_stroke).tif');
figure
subplot(231),imshow(f)
h = fspecial('average', 9);
g = imfilter(f, h, 'replicate');
subplot(232),imshow(g)
gB = im2bw(g, 0.5);
subplot(233),imshow(gB)
B = bwboundaries(gB, 'noholes');
d = cellfun('length', B);
[maxd, k] = max(d);
b = B{k};
[M N] = size(g);
g = bound2im(b, M, N);
subplot(234),imshow(g)
[s, su] = bsubsamp(b, 50);
g2 = bound2im(s, M, N);
subplot(235),imshow(g2)
cn = connectpoly(s(:, 1), s(:, 2));
g3 = bound2im(cn, M, N);
subplot(236),imshow(g3)
c = fchcode(su);
c.x0y0
c.fcc
c.mm
c.diff
c.diffmm

在这里插入图片描述

例8.3得到包围一个区域的边界的细胞组合体

clc,clear,close all;
f = imread('F:\qq\Digital-Image-Processing-main\Digital-Image-Processing-main\数字图像处理第三版 教材图片\DIP3E_CH12_Original_Images\DIP3E_Original_Images_CH12\Fig1209(b)(eye template).tif');
g = bwperim(f, 8);
Q = qtdecomp(g, 0, 2);
R = imfill(gF, 'holes') & g;
B = bwboundaries(f, 4, 'noholes');
b = B{1};

例8.4使用函数 im2minperpoly

clc,clear,close all;
f = imread('F:\qq\Digital-Image-Processing-main\Digital-Image-Processing-main\matlab教材示例图片\dipum_images_ch11\Fig1107(a)(mapleleaf).tif');
figure
subplot(321),imshow(f)
B = bwboundaries(f, 4, 'noholes');
b = B{1};
[M, N] = size(f);
bOriginal = bound2im(b, M, N);
subplot(322),imshow(bOriginal)
[X, Y] = im2minperpoly(f, 2);
b2 = connectpoly(X, Y);
bCellsize2 = bound2im(b2, M, N);
subplot(323),imshow(bCellsize2)

[X, Y] = im2minperpoly(f, 3);
b2 = connectpoly(X, Y);
bCellsize2 = bound2im(b2, M, N);
subplot(324),imshow(bCellsize2)

[X, Y] = im2minperpoly(f, 4);
b2 = connectpoly(X, Y);
bCellsize2 = bound2im(b2, M, N);
subplot(325),imshow(bCellsize2)

[X, Y] = im2minperpoly(f, 8);
b2 = connectpoly(X, Y);
bCellsize2 = bound2im(b2, M, N);
subplot(326),imshow(bCellsize2)

figure
[X, Y] = im2minperpoly(f, 10);
b2 = connectpoly(X, Y);
bCellsize2 = bound2im(b2, M, N);
subplot(221),imshow(bCellsize2)

[X, Y] = im2minperpoly(f, 16);
b2 = connectpoly(X, Y);
bCellsize2 = bound2im(b2, M, N);
subplot(222),imshow(bCellsize2)

[X, Y] = im2minperpoly(f, 20);
b2 = co
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

collapser_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值