Edge spline reconstruction... Easy Question

조회 수: 1 (최근 30일)
Francesco Pignatelli
Francesco Pignatelli 2023년 2월 8일
답변: Yash 2023년 3월 2일
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

채택된 답변

Yash
Yash 2023년 3월 2일
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 :)

추가 답변 (0개)

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by