资源简介
Matlab计算图像的 7 个不变矩示例代码,写得比较清楚,值得借鉴
代码片段和文件信息
I0=imread(‘lena.jpeg‘);
if isrgb(I0)==1
I1=rgb2gray(I0)
end
I2=imrotate(I1-4‘bilinear‘); %逆时针旋转4度
I3=fliplr(I1); %镜像
subplot(141)imshow(I1);
subplot(142)imshow(I2);
subplot(143)imshow(I3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%计算I1七个不变矩
%(1)计算I1的而质心
%(2)计算各阶中心矩
%(3)计算不变中心矩的值
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I1=double(I1);
[MN]=size(I1);
[xy]=meshgrid(1:M1:N);
x=x(:);
y=y(:);
I1=I1(:);
m00=sum(I1);
m10=sum(x.* I1);
m01=sum(y.* I1);
xcenter=m10/m00;
ycenter=m01/m00;
% 计算归一化的各阶中心矩,具有平移不变性和伸缩不变性
cm00=m00;
cm02=sum((y-ycenter).^2.*I1)/(m00^2);
cm11=sum((x-xcenter).*(y-ycenter).*I1)/(m00^2);
cm12=sum((x-xcenter).*(y-ycenter).^2.*I1)/(m00^2.5);
cm21=sum((x-xcenter).^2.*(y-ycenter).*I1)/(m00^2.5);
cm03=sum((y-ycenter).^3.*I1)/(m00^2.5);
cm30=sum((x-xcenter).^3.*I1)/(m00^2.5);
cm20=sum((x-xcenter).^2.*I1)/(m00^2);
%计算七个不变矩
im(1)=abs(log(cm20+cm02))
im(2)=abs(log((cm20-cm02)^2+4*cm11^2))
im(3)=abs(log((cm30-3*cm12)^2+(3*cm21-cm03)^2))
im(4)=abs(log((cm30+cm12)^2+(cm21+cm03)^2))
im(5)=abs(log((cm30-3*cm12)*(cm30+cm12)*((cm30+cm12)^2-3*(cm21+cm03)^2)+(3*cm21-cm03)*(cm21+cm03)*(3*(cm30+cm12)^2-(cm21+cm03)^2)))
im(6)=abs(log((cm20-cm02)*((cm30+cm12)^2-(cm21+cm03)^2)+4*cm11*(cm30-cm12)*(cm21+cm03)))
im(7)=abs(log((3*cm21-cm02)*(cm21+cm30)*((cm30+cm12)^2-3*(cm21+cm03)^2)-(cm30-3*cm12)*(cm21+cm03)*(3*(cm30+cm12)^2-(cm21+cm03)^2)))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 分别对三个图像进行不变矩的计算,结果证明他们的很接近。
%不变矩具有平移不变性、伸缩不变性、旋转不变性。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1830 2009-09-04 18:50 Invariant moments.m
----------- --------- ---------- ----- ----
1830 1
相关资源
- 合成孔径雷达RD算法Matlab仿真
- matlab-vs2012的编译配置文件
- 维纳在声音去噪中的应用MATLAB实现
- k均值聚类matlab
- BAYES决策的MATLAB程序设计
- matlab 混沌函数工具箱
- 基于MATLAB的PCM编码
- MATLAB建立的发动机的模型
- CRC校验 海明编码
- 基于单纯形寻优的PID参数整定方法
- MATLAB电机仿真模块
- 随机波束成型rbfmatlab代码
- RS编码MATLAB实现完整版
- 阶比仿真程序,matlab版
-
local self-similarity desc
riptor matlab cod - LPCC特征参数提取
- MATLAB去噪代码
- BP神经网络Matlab实现V1
- Matlab仿真ACO-OFDM信号发送与接收
- CroppedYale人脸数据降维 MATLAB
-
matlab simuli
nk 逆变器并网model VF/PQ控 - 优化问题测试函数matlab代码
- matlab 石头剪刀布
- ARIMA模型MATLAB实现代码
- ID3的MATLAB实现244799
- 最速下降法的MATLAB程序
- 彩色图像分割——matlab实现FCM算法
- 共轭梯度法的matlab实现
- matlab 对一个文件夹里的所有图像进行
- matlab FFT源代码
评论
共有 条评论