POLYNOMIALCURVESETFIT Fit a set of polynomial curves to a segmented image.
COEFS = polynomialCurveSetFit(IMG);
COEFS = polynomialCurveSetFit(IMG, DEG);
Result is a cell array of matrices. Each matrix is DEG+1-by-2, and
contains coefficients of polynomial curve for each coordinate.
IMG is first binarised, then skeletonized. Each cure
[COEFS LBL] = polynomialCurveSetFit(...);
also returns an image of labels for the segmented curves. The max label
is the number of curves, and the length of COEFS.
Requires the toolboxes:
- Optimization
- Image Processing
Example
% Fit a set of curves to a binary skeleton
img = imread('circles.png');
% compute skeleton, and ensure one-pixel thickness
skel = bwmorph(img, 'skel', 'Inf');
skel = bwmorph(skel, 'shrink');
figure; imshow(skel==0)
coeffs = polynomialCurveSetFit(skel, 2);
% Display segmented image with curves
figure; imshow(~img); hold on;
for i = 1:length(coeffs)
hc = drawPolynomialCurve([0 1], coeffs{i});
set(hc, 'linewidth', 2, 'color', 'g');
end
See also
polynomialCurves2d, polynomialCurveFit
Package: matgeom