
四、源码
1、读入钞票
function ima = getImage()
[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image
Files';...
'*.*','All Files' });
ima = imread([ pathname,filename]);
2、对纸币进行 radon 旋转矫正
l1=rgb2gray(l); %将真彩色图像转换为灰度图像
bw1=edge(l1,'sobel', 'both'); %采用 sobel 算子进行边缘检测
theta=0:179; %定义 theta 角度范围
r=radon(bw1,theta); %对图像进行 Radon 变换
%%%%%检测 Radon 变换矩阵中的峰值所对应的列坐标%%%%
[m,n]=size(r);
c=1;
for i=1:m
for j=1:n
if r(1,1)<r(i,j)
r(1,1)=r(i,j);
c=j;
end
end
end