第十一章 图像的描述子

1,傅里叶描述子
在这里插入图片描述

f=imread('ft.tif');
imshow(f)
b=boundaries(f);
b=b{1};
bim=bound2im(b,700,500);
imshow(bim)
z=frdescp(b);
z546=ifrdescp(z,546);
z546im=bound2im(z546,700,500);
imshow(z546im)


fourier.eng.hmc.edu/e161/dipum/
旋转不变矩

f=imread('ju.tif');%原图
imshow(f);
fp=padarray(f,[84 84],'both');%填充边框
imshow(fp);
fhs=f(1:2:end,1:2:end);%一半
fhsp=padarray(fhs,[184 184],'both');
imshow(fhsp)
fm=fliplr(f);%镜面
fmp=padarray(fm,[84 84],'both');
fr2=imrotate(f,2,'bilinear');%旋转
fr2p=padarray(fr2,[76 76],'both');
fr45=imrotate(f,45,'bilinear');
phiorig=abs(log(invmoments(f)));
phihalf=abs(log(invmoments(fhs)));
phimirror=abs(log(invmoments(fm)));
phifr2=abs(log(invmoments(fr2)));
phifr45=abs(log(invmoments(fr45)));

http://fourier.eng.hmc.edu/e161/dipum/invmoments.m``

图像矩求角度

F=imread('line.jpg');
F=double(F);
phif1=invmoments(F);

[M, N] = size(F);
[x, y] = meshgrid(1:N, 1:M);
  
% Turn x, y, and F into column vectors to make the summations a bit
% easier to compute in the following.
x = x(:);
y = y(:);
F = F(:);
  
% DIP equation (11.3-12)
m.m00 = sum(F);
% Protect against divide-by-zero warnings.
if (m.m00 == 0)
   m.m00 = eps;
end
% The other central moments:  
m.m10 = sum(x .* F);
m.m01 = sum(y .* F);
m.m11 = sum(x .* y .* F);
m.m20 = sum(x.^2 .* F);
m.m02 = sum(y.^2 .* F);
m.m30 = sum(x.^3 .* F);
m.m03 = sum(y.^3 .* F);
m.m12 = sum(x .* y.^2 .* F);
m.m21 = sum(x.^2 .* y .* F);
xc=m.m10/m.m00;
yc=m.m01/m.m00;
a=m.m20/m.m00-xc^2;
b=m.m11/m.m00-yc*xc;
c=m.m02/m.m00-yc^2;
theta=atan2(2*b,a-c)*90/pi

猜你喜欢

转载自blog.csdn.net/qq_41244435/article/details/83788664