How can I properly fit the skeleton in the first image?

5 views (last 30 days)
I tried 4th, 5th & 6th order polynomial fitting using polyfit. The curve needs to be split into 8 segments (shown in different colors) after the fitting. I need the tangent slope of each colored segment.
  3 Comments
yanqi liu
yanqi liu on 24 Jan 2022
yes,sir,what is split rule?use index to 8 equal space?
Krishnashish Bose
Krishnashish Bose on 24 Jan 2022
The split rule is 8 nearly equal segments. It is hard to maintain the length of the segments as the tail bends. That is another challenge different from what I asked about.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 24 Jan 2022
Why is it hard? Just figure out how many rows 1/8 of the total number of rows is and take those with regular indexing.
xy = rand(75, 2); % my (x,y) coordinates
[rows, columns] = size(xy);
startingRows = round(linspace(1, rows+1, 9)) % Use 9 instead of 8
endingRows = startingRows(2:end) - 1
for k = 1 : 8
fprintf('\nChunk %d had %d rows:\n', k, endingRows(k) - startingRows(k) + 1)
thisChunk = xy(startingRows(k) : endingRows(k), :)
fprintf('Chunk %d:\n', k)
% Now do something with this 1/8 chunk of the total array.
end
  4 Comments
Image Analyst
Image Analyst on 24 Jan 2022
Why did you sort the values by x? You need to sort them in order of moving along the curve of course. bwtraceboundary can do that buy you need to take only half the points because we don't want a "round trip" all the way around the blob. Or of course you could do it manually, or use bwdistgeodesic().
Find endpoints to get starting locations with bwmorph(bw, 'endpoints');

Sign in to comment.

Categories

Find more on Polynomials in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!