• 大小: 776B
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-16
  • 语言: Matlab
  • 标签: 不变矩  

资源简介

不变矩的matlab程序,经过验证 是正确的 ,很实用啊 ··········

资源截图

代码片段和文件信息

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


评论

共有 条评论