Edge spline reconstruction... Easy Question
1 回表示 (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!