why do i get error of ??? Error using ==> fchcode at 126 The input curve is broken or points are out of order.

1 view (last 30 days)
i am using a chaincode from the DIPUM toolbox and i have a silhouette of a hand image it is very clear and the function work correctly till the chain code is put on,i have this as a code g = bound2im(b, M, N); [s, su] = bsubsamp(b, 50); cn = connectpoly(s(:, 1), s(:, 2)); c = fchcode(su); is it something to do with the actual image

Answers (1)

Yuliang Xiu
Yuliang Xiu on 24 Dec 2016
Edited: Yuliang Xiu on 24 Dec 2016
This is because your sequence of points(su) is not in clockwise order.
I implement the clockwise order convert function as follows:
function [x y] = clockwise_order(x,y)
cx = mean(x);
cy = mean(y);
a = atan2(y - cy, x - cx);
[~, order] = sort(a);
x = x(order);
y = y(order);
end
hope this will help you

Community Treasure Hunt

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

Start Hunting!