Implementation of chain code method
-
Hi, hope every one is doing fine. i have started a project in which i will develop an online Urdu language Optical Character Recognition (OCR) system. i have been asked to apply chain code algorithm on image but i dont have any idea about this algorithm. i googled but cudnt find much helpfull material. if any one worked on Chain Code Algorithm plz help me, i want to know its basic theme and implementation guideline, further if anyone can provide me some sort of sample source code it will be great. Thanks in advance... Regards, Affan Ahmd Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
-
Hi, hope every one is doing fine. i have started a project in which i will develop an online Urdu language Optical Character Recognition (OCR) system. i have been asked to apply chain code algorithm on image but i dont have any idea about this algorithm. i googled but cudnt find much helpfull material. if any one worked on Chain Code Algorithm plz help me, i want to know its basic theme and implementation guideline, further if anyone can provide me some sort of sample source code it will be great. Thanks in advance... Regards, Affan Ahmd Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
Affan Toor wrote:
i googled but cudnt find much helpfull material.
What do you consider helpful?[^] Maybe you expected Google to find a genie that does your project for you. :rolleyes: On the first page of results is this page of source code[^] Good luck, you're going to need it.
led mike
-
Hi, hope every one is doing fine. i have started a project in which i will develop an online Urdu language Optical Character Recognition (OCR) system. i have been asked to apply chain code algorithm on image but i dont have any idea about this algorithm. i googled but cudnt find much helpfull material. if any one worked on Chain Code Algorithm plz help me, i want to know its basic theme and implementation guideline, further if anyone can provide me some sort of sample source code it will be great. Thanks in advance... Regards, Affan Ahmd Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
hi, Chain code is a compact way to represent a contour of an object. Commonly used chain code employs eight directions, which can be coded by 3-bit code words. Chain code contains the start pixel address followed by a string of code words. The chain code is an ordered sequence of n links {ci=1,2,............n}, where ci is a vector connecting neighboring contour pixels. The directions of ci are coded with integer values k = 0,1,......,K-1 in a counterclockwise sense starting from the direction of the positive x-axis. The number of directions K takes integer values where M is a positive integer. The chain codes where K>8 are called generalized chain codes. This is matlab implementation imdg=imread('o.png'); % input a thin image % im=zeros(250); or create a thin image % imd=padarray(im,[1,1],1,'both'); % imdg=padarray(imd,[20,20],0,'both'); imshow(imdg); [mm nn]=size(imdg); im=im2double(imdg); [m n]=size(im); n=[0 1;1 1;1 0;1 -1;0 -1;-1 -1;-1 0;-1 1]; flag=1; cc=[]; [x y]=find(im==1); x y x=min(x); imx=im(x,:); y=min(find(imx==1)); first=[x y]; first dir=7; while flag==1 tt=zeros(1,8); ndir=mod(dir+7,8); for i=0:7 j=mod(ndir+i,8)+1; tt(i+1)=im(x+n(j,1),y+n(j,2)); end d=min(find(tt==1)); dir=mod(ndir+d-1,8); cc=[cc,dir]; x=x+n(dir+1,1); y=y+n(dir+1,2); if x==first(1) & y==first(2) flag=0; end end the output cc contain the chain code
-
Hi, hope every one is doing fine. i have started a project in which i will develop an online Urdu language Optical Character Recognition (OCR) system. i have been asked to apply chain code algorithm on image but i dont have any idea about this algorithm. i googled but cudnt find much helpfull material. if any one worked on Chain Code Algorithm plz help me, i want to know its basic theme and implementation guideline, further if anyone can provide me some sort of sample source code it will be great. Thanks in advance... Regards, Affan Ahmd Toor
.................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
hi, Chain code is a compact way to represent a contour of an object. Commonly used chain code employs eight directions, which can be coded by 3-bit code words. Chain code contains the start pixel address followed by a string of code words. The chain code is an ordered sequence of n links {ci=1,2,............n}, where ci is a vector connecting neighboring contour pixels. The directions of ci are coded with integer values k = 0,1,......,K-1 in a counterclockwise sense starting from the direction of the positive x-axis. The number of directions K takes integer values where M is a positive integer. The chain codes where K>8 are called generalized chain codes. This is matlab implementation imdg=imread('o.png'); % input a thin image % im=zeros(250); or create a thin image % imd=padarray(im,[1,1],1,'both'); % imdg=padarray(imd,[20,20],0,'both'); imshow(imdg); [mm nn]=size(imdg); im=im2double(imdg); [m n]=size(im); n=[0 1;1 1;1 0;1 -1;0 -1;-1 -1;-1 0;-1 1]; flag=1; cc=[]; [x y]=find(im==1); x y x=min(x); imx=im(x,:);% it is full colon y=min(find(imx==1)); first=[x y]; first dir=7; while flag==1 tt=zeros(1,8); ndir=mod(dir+7,8); for i=0:7 j=mod(ndir+i,8)+1; tt(i+1)=im(x+n(j,1),y+n(j,2)); end d=min(find(tt==1)); dir=mod(ndir+d-1,8); cc=[cc,dir]; x=x+n(dir+1,1); y=y+n(dir+1,2); if x==first(1) & y==first(2) flag=0; end end the output cc contain the chain code philumon