资源简介
硕士期间自己编写的边缘提取程序。以CMU步态库中的图像为例,提取人的轮廓。包括形态学运算、孔洞填充、平滑、标签等一系列操作,每个步骤均有注释,程序可读性强。
以下是代码片段:
% imclose the image
se=strel('disk',3);
f6=imclose(f5,se);
figure(4);
imshow(f6);
% fill the image
f8=imfill(f6);
figure(5);
imshow(f8);
% smooth the image
f9=double(f8)/255;
f10=medfilt2(f9,[3 3]);
figure(6);
imshow(f10,[]);
% add label to the image
bw1=im2bw(f10);
[x,num]=bwlabel(bw1,4);
...

代码片段和文件信息
clc;
clear all;
%reading and showing
f1=imread(‘foreground.jpg‘);
%converting color image to grayimage
f2=rgb2gray(f1);
figure(1)imshow(f2);
%reading and showing
f3=imread(‘background.jpg‘);
%converting color image to grayimage
f4=rgb2gray(f3);
figure(2)imshow(f4);
%background subtracting
f5=abs(double(f2)-double(f4));
[M N]=size(f5);
T=20;
for i=1:M
for j=1:N
if f5(ij)>T
f5(ij)=255;
else
f5(ij)=0;
end
end
end
f5=uint8(f5);
figure(3);
imshow(f5);
% imclose the image
se=strel(‘disk‘3);
f6=imclose(f5se);
figure(4);
imshow(f6);
% fill the image
f8=imfill(f6);
figure(5);
imshow(f8);
% smooth the image
f9=double(f8)/255;
f10=medfilt2(f9[3 3]);
figure(6);
imshow(f10[]);
% add label to the image
bw1=im2bw(f10);
[xnum]=bwlabel(bw14);
% calculate the number of pixels of each labeled area
long=1:num;
for i=1:num
[rc]=find(x==i);
rc=[r c];
long(i)=size(rc1);
end
% display the number of pixels of each labeled area
for j=1:num
disp(long(j));
end
% calculate which area has the biggest number of pixels
max=0;
for k=1:num
if(long(k)>max)
max=long(k);
m=k;
end
end
% the label of the biggest area
m
% the number of pixels of the biggest area
max
% get the image of the biggest area
[row column]=size(x);
for i=1:row
for j=1:column
if(x(ij)==m)
x(ij)=m;
else x(ij)=0;
end
end
end
se=strel(‘disk‘2);
x=imerode(xse);
% display the image
figure(7)imshow(x);
% get the edge of the image
y=edge(x‘canny‘);
figure(8)imshow(y);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2009-05-04 21:35 CMU\
文件 43648 2001-04-06 20:25 CMU\background.jpg
文件 1645 2005-05-30 18:18 CMU\edge1.asv
文件 1663 2008-03-01 09:56 CMU\edge1.m
文件 47037 2001-04-06 19:17 CMU\foreground.jpg
相关资源
- 组合导航matlab程序
- 替代数据法的matlab程序
- 神经网络分类matlab程序
- matlab程序用Hopfield网络解决TSP
- 多用户检测MATLAB程序
- 实现2ask.4ask.2fsk.4fsk.qam16.qam8调制的m
- 曲线旋转得到曲面的MATLAB程序
- 主动轮廓模型算法matlab程序
- Lozi混沌系统相关分析的MATLAB程序
- 用蚁群算法求解TSP问题的matlab程序
- Matlab图像分割边缘提取算法
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- KF+EKF matlab程序实现
- 圆拟合matlab程序,以及圆心 半径的确
- stlwritematlab程序
- 层次分析法的matlab程序
- 泊松过程的模拟及检验 matlab程序
- 世上最牛的23个图像跟踪算法MATLAB程序
- 散点拟合平面的MATLAB程序
- 信号检测与估计-理论与应用答案及
- ROC曲线MATLAB程序
- dijkstra算法改进的matlab程序能求出两点
- EEMD的MATLAB程序
- 基于遗传算法的机器人路径规划matl
- 基于自适应压扩法降低OFDM系统的峰均
- 求露点温度matlab程序
- 计算图像Spatial Frequence的Matlab程序SF
- 德州扑克获胜概率计算的MATLAB程序
- 数模美赛常用模型算法matlab程序包+数
评论
共有 条评论