数字信号与图像处理相关技术及实现
1. 图像旋转与阈值处理
1.1 图像旋转
在图像处理中,图像旋转是常见的操作。以下是一段实现图像旋转相关计算的代码:
MRotM=[cos(thet) sin(thet);-sin(thet) cos(thet)];
V=[nC-xor;yor-nR];
VmR=MRotM*V;
Cl=(VmR(1,:) < Xor-0.5) & (VmR(1,:) > -Xor+0.5);
C2= (VmR(2,:) < Yor-0.5) & (VmR(2,:) > -Yor+0.5);
nbool=Cl & C2;
1.2 Otsu方法阈值计算
Otsu方法是一种常用的图像二值化方法,用于计算图像的最佳阈值。
1.2.1 阈值计算函数
function [threshold,Hs]=otsu(pixc)
[nlig ncol]=size(pixc);
Lhist=256; histog=zeros(Lhist,1);
for k=1:Lhist
histog(k)=length(find(pixc==k-1));
end
histog=histog/nlig/ncol;
Pinf=0; Psup=1; sinf=0; muinf=0;
ssup=(0:Lhist-1)*histog
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



