Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. Implementation of chain code method

Implementation of chain code method

Scheduled Pinned Locked Moved IT & Infrastructure
algorithmshelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Affan Toor
    wrote on last edited by
    #1

    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!

    L P 3 Replies Last reply
    0
    • A Affan Toor

      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!

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • A Affan Toor

        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!

        P Offline
        P Offline
        philumon
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • A Affan Toor

          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!

          P Offline
          P Offline
          philumon
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups