How can I find multiple elements in an array?
2 views (last 30 days)
Show older comments
Hi,
I have two edge images, edgeIm1 and edgeIm2, and I only want to keep the common edge between the two.
% number the edges of edgeIm1
labelIm = bwlabel(edgeIm1);
% only keep the edges in edgeIm1 that have points in common with the edges in edgeIm2
buffIm = labelIm .* edgeIm2;
%store the values of the common edges in a vector
vals = unique(buffIm(:));
vals(vals == 0) = [];
%Create a cleaned up edge image using only the edges in edgeIm1
cleanEdgeIm = false(size(edgeIm1));
for i = 1:length(vals)
cleanEdgeIm = (cleanEdgeIm | labelIm == vals(i));
end
Is there a faster way to accomplish this than by looping through every element of the vector?
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!