Matlab实现人民币币值的显示 实现代码
上图像和程序了……记得程序好像是很久以前收藏的了……分享出来了……
clear all;clc;
Img = imread('I.jpg');
if ndims(Img)==3
I=rgb2gray(Img);
else
I=Img;
end
I1=imcomplement(I);
bw = im2bw(I1,0.7);
imshow(bw);title('初始二值图像');
bw(1:round(1/4*size(bw,1)),:)=0;
bw(round(1/2*size(bw,1)):end,:)=0;
bw(:,1:round(0.28*size(bw,2)))=0;
bw(:,round(0.55*size(bw,2)):end)=0;
figure,imshow(bw);title('只含有数字区域');
L=bwlabel(bw);
stats=regionprops(L);
Ar=cat(1,stats.Area);
[ar,ind]=sort(Ar,'descend');
bw1=bw;bw2=bw;bw3=bw;
bw1(L~=ind(1))=0;
bw2(L~=ind(2))= 0;
bw3(L~=ind(3))=0;
bw=bw1+bw2+bw3;
bw=imdilate(bw,strel('disk', 3));
figure,imshow(bw);
[r,c]=find(bw);
figure;
imshow(Img);
title('原图')
for i=1:length(r)
Img(r(i),c(i),1)=255;
Img(r(i),c(i),2)=0;
Img(r(i),c(i),3)=0;
end
figure,
imshow(Img);
title('标记图')