How to pass from a set of points to lines interpolating them?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone! I have obtained the following skeletonization
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1029925/image.jpeg)
However, if you zoom, you see that the pink lines are not lines but they are series of rectangles that contain points, like you can see in this figure here below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1029930/image.jpeg)
I would like to know how to pass from these points (contained in the rectangles) to approximate lines that trace the skeletonization in pink (Maybe there is an approximative interpolation that can do this (?)). Could anyone help me? Thanks in advance
4 Commenti
Risposta accettata
Matt J
il 12 Giu 2022
Modificato: Matt J
il 12 Giu 2022
Image=load('codice_opcode.mat').out;
B=bwboundaries(Image); B(1)=[];
imagesc(Image); colormap(gray); axis image;
hold on
for i=1:numel(B)
[x,y]=cellBoundary(Image,B{i});
plot(x,y,'r','LineWidth',2)
end
hold off
zoom(4)
function [x,y]=cellBoundary(BW,b)
sz=size(BW);
Z=false(sz);
Z( sub2ind(sz,b(:,1),b(:,2)) )=1;
Z=imdilate(Z,ones(3))&BW;
b=bwboundaries(Z,'noholes');
[x,y]=deal(b{1}(:,2), b{1}(:,1));
end
4 Commenti
Matt J
il 14 Giu 2022
Just put the output of cellBoundary somewhere convenient, e.g.,
[x{i},y{i}]=cellBoundary(Image,B{i});
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Visual Exploration 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!