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
P

philumon

@philumon
About
Posts
2
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Implementation of chain code method
    P philumon

    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

    IT & Infrastructure algorithms help

  • Implementation of chain code method
    P philumon

    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

    IT & Infrastructure algorithms help
  • Login

  • Don't have an account? Register

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