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

3 visualizzazioni (ultimi 30 giorni)
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 Commenti
yanqi liu
yanqi liu il 24 Gen 2022
yes,sir,what is split rule?use index to 8 equal space?
Krishnashish Bose
Krishnashish Bose il 24 Gen 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.

Accedi per commentare.

Risposte (1)

Image Analyst
Image Analyst il 24 Gen 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 Commenti
Krishnashish Bose
Krishnashish Bose il 24 Gen 2022
Here is how your code incorrectly grouped the points:
Image Analyst
Image Analyst il 24 Gen 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');

Accedi per commentare.

Categorie

Scopri di più su Polynomials in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by