Code covered by the BSD License

### Highlights from Freeman Chain Code

5.0

5.0 | 4 ratings Rate this file 69 Downloads (last 30 days) File Size: 2.35 KB File ID: #29518

# Freeman Chain Code

24 Nov 2010

Gives Freeman chain code 8-connected representation of a boundary

File Information
Description

usage:
--------------------------------------------------------
[cc] = chaincode(b,u)

INPUT:
--------------------------------------------------------
b - boundary as np-by-2 array
unwrap - (optional, default=false) unwrap code

OUTPUT:
--------------------------------------------------------
cc is a structure with the following fields:
cc.code - 8-connected Freeman chain code 1-by-np
cc.x0,cc.y0 - coordinates of start point
cc.ucode - unwrapped 8-connected Freeman chain code

MATLAB release MATLAB 7.8 (R2009a)
07 Oct 2013

can anyone give me an example on how to call or use this function. I am totally new on matlab and need to see how this chaincode works? many thanks and really appreciate it

12 Jun 2013

Worked fine for me, thank you very much for the comments, they were VERY helpful!

30 Aug 2012

i was running this function and i get output like this :
CC =
x0:0
y0:0
code:[209x1 double], would you explain it for me ?

18 May 2012

would you tell me please the exact steps to run this code ??
than you :)

09 May 2012

Hi Ann, look to my previous comments (ex. 19/3/2011) the b parameter is an array containing coords of boundary points that should be 8-connected. 8-connected means that if Bn is the n-th element of b and Bn+1 the next their x y coords should satisfy this relations: | Xn - Xn+1 |<=1 AND | Yn - Yn+1 |<=1. Start checking that with a simple example. Regards Alessandro

08 May 2012

i am trying to use this code on the image but i am getting the error "Curve isn't 8-connected in elements: "

what to do?

17 Apr 2012

Hi Frb, please note than b contains coords of boundary points order so that they are 8-connected. The find function you use return coords of boundary points but in a different order. From Matlab Help seems it scans matrix column by column. Best regards Alessandro

08 Apr 2012

hello,
I checked this code, seems very useful but I have problem, I give this piece of code to make it 8-connected:
BW1=im2bw(I);
BW1=~BW1;
BW2 = bwperim(BW1,8);
image=BW2;
[x y]=find(image==1);
b=[x y];
and then I put the result in b,
when I run the code error applies and says Curve isn''t 8-connected in elements. I appreciate any help.

Kind Regards,
Fariba

23 Mar 2012

if i have an image what's the procedure to find the chain code for that particular image !

14 Mar 2012

Thanks for your great work, and I have a question :-
I have image called XYZ.png and I passed that images to this function but I found an error.

28 Feb 2012

i had a skeleton with me which i want to give as a input to this chaincode..and when i tried to do that...i am getting that subscript indices are must be either positive or real...please somebody help me in resolving this...

30 May 2011

i have a silhouette for human image(http://i.imgur.com/fTwkZ.png) and I put the image boundary in an array and then i passed it to the Freeman Chain Code function. this image shows the body boundary is connected to each other but in real it gives me this error
"Curve isn't 8-connected in elements:
idx -> 350
idx -> 700
idx -> 1050
idx -> 1400
....
"

so can any one help me please? :)

19 Mar 2011

Look at description inside source code:

% b - boundary as np-by-2 array;
% np is the number of pixels and each element is a pair (y,x) of
% pixel coordinates

For example, if you have 4 points p=(y,x) like this p1=(5,1);p2=(5,2);p3=(4,2);p4=(3,1) b is:

b = [ 5 1;5 2;4 2;3 1]

note that points must be 8-connected.

19 Mar 2011

hi,
what should be the input for "b"?
is it an image or what ??
need help as soon as possible pls ..
thanx

19 Mar 2011

A very nice self explanatory code!!
Was very useful for my project.
Great job!!!!!!!!!