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

3 ビュー (過去 30 日間)
Krishnashish Bose
Krishnashish Bose 2022 年 1 月 23 日
コメント済み: Image Analyst 2022 年 1 月 24 日
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 件のコメント
yanqi liu
yanqi liu 2022 年 1 月 24 日
yes,sir,what is split rule?use index to 8 equal space?
Krishnashish Bose
Krishnashish Bose 2022 年 1 月 24 日
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.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2022 年 1 月 24 日
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 件のコメント
Krishnashish Bose
Krishnashish Bose 2022 年 1 月 24 日
Here is how your code incorrectly grouped the points:
Image Analyst
Image Analyst 2022 年 1 月 24 日
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');

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by