使用matlab中的模板匹配进行货币识别

时间:2014-03-28 10:03:10

标签: matlab image-processing roi template-matching

我正在尝试使用Mat-lab中的图像处理进行货币识别。我正在尝试的是从纸币扫描图像中获取ROI并将其用作模板以将其与原始纸币图像进行比较。在这种情况下,我将为每种纸币设置模板,然后将每个模板与每种纸币图像进行比较。我从原始图像中裁剪了模板(我有ROI)。在进行模板匹配与相关之后,我得到了着色系数矩阵。我的问题是比较这些矩阵来命名货币。任何人都可以帮助我,或建议我采用不同的方法解决问题?

只是为了澄清我的问题:

我有1,5,10,50和100单位货币。我有这些货币的扫描图像。而且我还为每种货币模板形成了货币图像。现在我尝试使用模板匹配将模板与货币图像进行匹配。例如,在将1单位模板的模板与每张纸币图像(1,5,10,50和100单位图像)匹配时,我得到了五个相关矩阵。我的问题是在这五个相关矩阵之间进行比较,以确定与正确的货币票据匹配的那个,在这种情况下是1单位模板。

以下是我的简单代码:

% Read the currency images
Note1 = imread('1.jpg');
Note2 = imread('5.jpg');
Note3 = imread('10.jpg');
Note4 = imread('50.jpg');
Note5 = imread('100.jpg');

%Change the images into gray-scale 
Note1=rgb2gray(Note1);
Note2=rgb2gray(Note2);
Note3=rgb2gray(Note3);
Note4=rgb2gray(Note4);
Note5=rgb2gray(Note5);

% Crop the templates non-interactively
Crop_Rec= [50 250 100 250]; 

sub_Note1 = imcrop(Note1,rect_Note1);
sub_Note2 = imcrop(Note2,rect_Note2);
sub_Note3 = imcrop(Note3,rect_Note3);
sub_Note4 = imcrop(Note4,rect_Note4);
sub_Note5 = imcrop(Note5,rect_Note5);

% This can be repeated with a loop changing the template from sub_Note1 through sub_Note5

template=sub_Note1;

c1 = xcorr2(template, Note1);
c2 = xcorr2(template, Note2);
c3 = xcorr2(template, Note3);
c4 = xcorr2(template, Note4);
c5 = xcorr2(template, Note5);

重复5个模板(sub_Note1到sub_Note5)的相关性后,我将有25个相关矩阵。我的目的是比较这些矩阵并找到最佳匹配。

0 个答案:

没有答案
相关问题