Total members 11895 |It is currently Mon Dec 30, 2024 6:01 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Simple and easy freeman Chain Code algorithm code implementation , This implementation is used to detecting edges in binary images ( 0's,1's pixels), this code start by searching the binary image until it finds a 0 (black pixel).

freeman.m
matlab code
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
end


m(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
newcol

end



checkones.m
matlab code
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 ;




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

For this message the author DrRakha has received gratitude : bil
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Freeman chain code algorithm code
 apriori algorithm c code     -  
 apriori algorithm java code     -  
 java code for decision tree algorithm     -  
 LZW data compression-decompression algorithm java code     -  
 quicksort algorithm implementation java code- array sorting     -  
 balloon sort algorithm C++ implementation code-sorting array     -  
 Bubble Sort Algorithm Java Implementation Code-Sorting Array     -  
 i want code for connecting mobile and pc can u send me code     -  
 asking for code     -  
 code     -  



Topic Tags

Matlab Algorithms
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com