Hello guys.
I am currently developing an OCR tool using Chain-code algorithm in Java. I was googling and found this code in Matlab. I have no idea on using Matlab.
So, I need help from someone who's good in Matlab to convert it into Java. This will be a big help for me as I really need to get this code ready asap.
Here is the code:
1. checkones.m
function [c]=checkones(m,row,col)
c=0;
if(row==1)
c=1
else
if(m(row-1,col)==1)
c=1 ;
end
end
return ;
freeman.m
function []=freeman()
clc
m=imread('C:\Documents and Settings\Desktop\msi.bmp');[h w d]=size(m);
h;
w;
d;
m
row=0;
col=0;
for i=w:-1:1 % column
for j=1:1:h % row
% m(j,i)
if(m(j,i)==0)
row=j;
col=i;
break;
end
end
endm(row,col);
oldrow=row;
oldcol=col;
newrow=-1;
newcol=-1;
%while (row ~=newrow & col ~= newcol )
for i=1:300;if(checkones(m,oldrow,oldcol)==1)%up 1 %your up is 1 if(m(oldrow,oldcol+1)==1)%righ 1 if(m(oldrow+1,oldcol)==1)%down 1 break; else newrow=oldrow+1; newcol=oldcol; end else newrow=oldrow; newcol=oldcol+1; end else% your up is 0 if(m(oldrow,oldcol+1)==1)%down newrow=oldrow+1; newcol=oldcol; else if(m(oldrow,oldcol+1)==0 &m(oldrow,oldcol-1)~=1)% rigth newrow=oldrow; newcol=oldcol+1; else if(m(oldrow,oldcol-1)==1)% up newrow=oldrow-1; newcol=oldcol; end end
oldrow=newrow;
oldcol=newcol;
newrow
newcolend
Hope any of you guys can help me on this. Thanks in advance.