Freeman chain code

19 次查看(过去 30 天)
Hello ,
It is very urgent .I need to generate a freeman chain code of a character contour. Please read the comment lines .I get an error . If anyone [particularly the author Alessandro Mannini <mailto:mannini@esod.it mannini@esod.it> ] could resolve it , please avail me the answers . It will be helpful for my research .
my matlab file is as follows
clc;
close all;
clear all;
%READ THE IMAGE , NOTE :THE BACKGROUND IS WHITE AND FOREGROUND IS BLACK
im1 =imread('D:\SAIGEETHA\ME\V SEMESTER\MINI PROJECT\000t01.tif');
% FIND THE COORDIANTES OF THE FIRST OCCURENCE OF THE BALCK PIXEL OF THE
% GIVEN IMAGE
[r,c]=find(im1==0,1,'first');
%TRACE THE CONTOUR OF THE CHARACTER USING contour_trace.m
%contour_trace.m is downloaded from file Exchange
% Syntax :
% [pixel,I]=contour_trace(BW,r,c)
%
% Input :
% r,c - row, column value of a single pixel on the contour.
% BW - Black & White Image (Binary Image).
%
% Output :
% I - Binary Image containing just the desired contour.
% pixel - N x 2 matrix which stores the pixel value of the contour,
% column1 gives the rows & column2 the corresponding column.
[pixel,I]=contour_trace(im1,r,c);
%SWAPPED THE COLUMNS B'COZ THE b INPUT OF THE chaincode(b,unwrap) FUNCTION
%SHOULD BE (y,x) .
% INPUT:
% --------------------------------------------------------
% b - boundary as np-by-2 array;
% np is the number of pixels and each element is a pair (y,x) of
% pixel coordinates
% unwrap - (optional, default=false) unwrap code;
% if enable phase inversions are eliminated
%
b=cat(2,pixel(:,2),pixel(:,1));
% GENERATE THE CHAIN CODE
c=chaincode(b,true);
*THE ERROR IS AS FOLLOWS *
??? Error using ==> chaincode at 77
Curve isn't 8-connected in elements:
With regards
Saigeetha
  2 个评论
Walter Roberson
Walter Roberson 2011-12-2
This question follows on the (unanswered) question http://www.mathworks.com/matlabcentral/answers/22219-freeman-chain-code

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2011-12-2
The routine you appear to be using is http://www.mathworks.com/matlabcentral/fileexchange/29518-freeman-chain-code/content/chaincode.m which is a user file contribution, not part of MATLAB itself. I see that error message in that code.
The error message means that some element of the contour you are feeding in, is not immediately adjacent to another pixel. The test used is whether all the coordinates differ by no more than 1 in x and y from the pixel immediately before. You can apply the same test to the list of rows and columns returned by contour_trace and then work on figuring out why it happens.
I imagine it would happen if the character has parts that are not touching the rest. Freeman code chains are not intended to handle characters that have discontinuous outlines. For example, Freeman code chains are not intended to be able to handle the separated dot on top of the lower-case I

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by