Edge spline reconstruction... Easy Question

1 vue (au cours des 30 derniers jours)
Francesco Pignatelli
Francesco Pignatelli le 8 Fév 2023
Réponse apportée : Yash le 2 Mar 2023
Dear all,
I have an image I want to extract the edge, reconstruct it with a spline and then save the results as image array. I have binarized the image first, then used bwboundaries to get the edge and then sline. However, I would like to have the same type of output that is given by the MATLAB fuction edge() (which is a matrix). How can I do that? So basically I need to build up a matrix from a list of vectors, so that if I use the imasc() function, I can see all my recontstructed edges.
I attach my code, the image and the fuction I use to get the reconstructed edge.
Best regards
Fracesco

Réponse acceptée

Yash
Yash le 2 Mar 2023
Hi Francesco Pignatelli,
To convert the ouput of the bwboundaries into a matrix of edge values like the function edge() does, you can create a zero matrix of the size(BW), iterate through the output of the bwboundaries and mark the corresponding indices as 1 in the newly created matrix.
Here's some example code :
In your attached file Sigur.m you can modify the for loop to this
edgeMatrix = zeros(size(BW));
for i = 1:numel(boundaries)
boundary = boundaries{i};
[row,~] = size(boundary);
for i = 1:row
x = boundary(i,1);
y = boundary(i,2);
edgeMatrix(x,y) = 1;
end
% xy = boundaries{i};
% plot(xy(:,2),xy(:,1),".")
end
imwrite(edgeMatrix, 'edgeMatrix.png');
With this you can see all the reconstructed edges. I hope this helps :)

Plus de réponses (0)

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by