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

3 Ansichten (letzte 30 Tage)
Krishnashish Bose
Krishnashish Bose am 23 Jan. 2022
Kommentiert: Image Analyst am 24 Jan. 2022
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 Kommentare
yanqi liu
yanqi liu am 24 Jan. 2022
yes,sir,what is split rule?use index to 8 equal space?
Krishnashish Bose
Krishnashish Bose am 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 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 Kommentare
Krishnashish Bose
Krishnashish Bose am 24 Jan. 2022
Here is how your code incorrectly grouped the points:
Image Analyst
Image Analyst am 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');

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Polynomials finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by