clear;X=imread('bank.png');X=double(X(13:42,:,1));X=255-X;%Digits 30X18.
I(1,:)=[17:34];I(2,:)=[50:67];I(3,:)=[78:95];I(4,:)=[111:128];I(5,:)=[140:157];
I(6,:)=[170:187];I(7,:)=[202:219];I(8,:)=[232:249];I(9,:)=[262:279];I(10,:)=[292:309];
%for J=1:10;XX(:,I(J,:))=X(:,I(J,:));end;
YY=[X(:,I(1,:)) X(:,I(2,:)) X(:,I(3,:)) X(:,I(4,:)) X(:,I(5,:)) X(:,I(6,:))];
YY=[YY X(:,I(7,:)) X(:,I(8,:)) X(:,I(9,:)) X(:,I(10,:))];
for J1=1:10;R=[];for J2=1:10;R(J2)=sum(sum(YY(:,[1:18]+(J1-1)*18).*X(:,I(J2,:))));end;
[Z,D]=max(R);K(J1)=rem(D,10);end;subplot(211),imagesc(YY),colormap(gray),subplot(212),stem(K)
%XX(:,:,1)=X(:,17:34);XX(:,:,2)=X(:,50:67);XX(:,:,3)=X(:,78:95);
%XX(:,:,4)=X(:,111:128);XX(:,:,5)=X(:,140:157);XX(:,:,6)=X(:,170:187);
%XX(:,:,7)=X(:,202:219);XX(:,:,8)=X(:,232:249);XX(:,:,9)=X(:,262:279);
%XX(:,:,10)=X(:,292:309);XXX=[XX(:,:,1) XX(:,:,2) XX(:,:,3) XX(:,:,4)];
%XXX=[XX XX(:,:,5) XX(:,:,6) XX(:,:,7) XX(:,:,8) XX(:,:,9) XX(:,:,10)];
%for I=1:10;for K=1:10;R=sum(sum(XXX(:,[1:17]+.*XX(:,:,K)))
%for L=1:10;R(L)=sum(sum(XX(:,:,10).*XX(:,:,L)));end;[Y,D]=max(R);D

clear;X=imread('bank.png');X=double(X(13:42,:,1));X=255-X;%Digits 30X18.
I(1,:)=[17:34];I(2,:)=[50:67];I(3,:)=[78:95];I(4,:)=[111:128];I(5,:)=[140:157];
I(6,:)=[170:187];I(7,:)=[202:219];I(8,:)=[232:249];I(9,:)=[262:279];I(10,:)=[292:309];
YY=[X(:,I(2,:)) X(:,I(2,:)) X(:,I(1,:)) X(:,I(3,:)) X(:,I(7,:)) X(:,I(1,:))];
YY=[YY X(:,I(3,:)) X(:,I(5,:)) X(:,I(6,:))];
for J1=1:9;for J2=1:10;R(J2)=sum(sum(YY(:,[1:18]+(J1-1)*18).*X(:,I(J2,:))));end;
[Z,D]=max(R);K(J1)=rem(D,10);end;subplot(211),imagesc(YY),colormap(gray),subplot(212),stem(K)

clear;X=imread('bank.png');X=double(X(13:42,:,1));X=255-X;%Digits 30X18.
I(1,:)=[17:34];I(2,:)=[50:67];I(3,:)=[78:95];I(4,:)=[111:128];I(5,:)=[140:157];
I(6,:)=[170:187];I(7,:)=[202:219];I(8,:)=[232:249];I(9,:)=[262:279];I(10,:)=[292:309];
%for J=1:10;XX(:,I(J,:))=X(:,I(J,:));end;
YY=[X(:,I(10,:)) X(:,I(1,:)) X(:,I(2,:)) X(:,I(3,:)) X(:,I(4,:)) X(:,I(5,:)) X(:,I(6,:))];
YY=[YY X(:,I(7,:)) X(:,I(8,:)) X(:,I(9,:)) ];
for J1=1:10;for J2=1:10;R(J2)=sum(sum(YY(:,[1:18]+(J1-1)*18).*X(:,I(J2,:))));end;
[Z,D]=max(R);K(J1)=rem(D,10);end;subplot(211),imagesc(YY),colormap(gray),subplot(212),stem(K)