Clear Filters
Clear Filters

how to make the image suitable for recognition using hit or mis

1 view (last 30 days)
X=imread('testimage1.bmp');
%imshow(X)
%intrec(X)
%The digits found in the image are:
%0
%3
%5
%--------------------------------------------------------------------------
%Authors: Jahanzeb Rajput and Mohammad Fahad
%Department of Electrical Engineering
%University of Engineering and Technology, Lahore, Pakistan.
%--------------------------------------------------------------------------
Z=X;
A= imread ('zero.bmp');
A=imresize(A,[41,35]);
A=bwmorph(A,'thin',26);
B= imread ('one.bmp');
C= imread ('two.bmp');
D= imread ('three.bmp');
E= imread ('four.bmp');
F= imread ('five.bmp');
G= imread ('six.bmp');
H= imread ('seven.bmp');
I= imread ('eight.bmp');
J= imread ('nine.bmp');
%SE 2
SE = strel('square',3);
K=imdilate(A,SE);A2=K-A;
L=imdilate(B,SE);B2=L-B;
M=imdilate(C,SE);C2=M-C;
N=imdilate(D,SE);D2=N-D;
O=imdilate(E,SE);E2=O-E;
P=imdilate(F,SE);F2=P-F;
Q=imdilate(G,SE);G2=Q-G;
R=imdilate(H,SE);H2=R-H;
S=imdilate(I,SE);I2=S-I;
T=imdilate(J,SE);J2=T-J;
%-------------------------
%Hit or Miss
%-------------------------
disp('The digits found in the image are:');
if ~isempty(nonzeros(bwhitmiss(Z,A,A2)))
disp('0');
end
%imshow('num1.bmp')
%U=bwhitmiss(Z,F,F2);
%figure
%imshow(U)
if ~isempty(nonzeros(bwhitmiss(Z,B,B2)))
disp('1');
end
if ~isempty(nonzeros(bwhitmiss(Z,C,C2)))
disp('2');
end
if ~isempty(nonzeros(bwhitmiss(Z,D,D2)))
disp('3');
end
if ~isempty(nonzeros(bwhitmiss(Z,E,E2)))
disp('4');
end
if ~isempty(nonzeros(bwhitmiss(Z,F,F2)))
disp('5');
end
if ~isempty(nonzeros(bwhitmiss(Z,G,G2)))
disp('6');
end
if ~isempty(nonzeros(bwhitmiss(Z,H,H2)))
disp('7');
end
if ~isempty(nonzeros(bwhitmiss(Z,I,I2)))
disp('8');
end
if ~isempty(nonzeros(bwhitmiss(Z,J,J2)))
disp('9');
end
This code will work only the character
size of the integers present in the image should be exactly 26. How can we make the image as suitable for this. Example images shown here

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!