spline for corner object
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Mehri Mehrnia
il 24 Lug 2022
Commentato: Jeffrey Clark
il 27 Lug 2022
I have a contour that I have extracted important points of it based on detectHarrisFeatures. Now I need to connect these points with spline using cscvn function to get the primary contour. But, points fed into cscvn function need to be in a order but the the output points of detectHarrisFeatures are not in order. sort function does not work as its the closed contour and the numbers are not in ascending/descending order. I've attached main image that I've extracted the contour and corner points.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1075650/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1075650/image.jpeg)
0 Commenti
Risposta accettata
Jeffrey Clark
il 24 Lug 2022
@Mehri Mehrnia, use Transform Cartesian coordinates to polar or cylindrical - MATLAB cart2pol (mathworks.com) and sort by theta to get the sort index return [~,I] = sort(theta), then use I to index your cartesian data in a proper order.
1 Commento
Jeffrey Clark
il 27 Lug 2022
@Mehri Mehrnia, thanks for accepting. @David Goodmanson's answer shows that an appropriate selection for the cartesian central point is needed for either of these to work; for your case probably just the mean x and y. But depending on the image irregularities, outline points selection, fidelity etc it may be difficult to find one central point where its rays don't intesect a concave extent (from the chosen point's perspective).
Più risposte (1)
David Goodmanson
il 24 Lug 2022
HI Mehri,
try sorting by angle around a point in the center:
x0 = 350;
y0 = 325;
theta = atan2(y-y0,x-x0);
[~,ind] = sort(theta);
xnew = x(ind);
ynew = y(ind);
0 Commenti
Vedere anche
Categorie
Scopri di più su Splines 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!