How write Matlab code to plot boundaries of edges if they match edges in another image?

1 vue (au cours des 30 derniers jours)
asdf
asdf le 26 Fév 2019
Commenté : asdf le 26 Fév 2019
I have a Matlab code written here:
function matchObj2Outline(Sample, Outline)
[B,L,N] = bwboundaries(Outline);
SampleBoundaries={};
OutlineBoundaries={};
for k=1:length(B),
boundary = B{k};
BL=size(boundary);
OutlineBoundaries{end+1}=[boundary(:,2) boundary(:,1)];
end
[B,L,N] = bwboundaries(Sample);
figure(1); imshow(Sample); hold on;
%find boundaries on Sample that match with boundaries in Outline
for k=1:length(B),
boundary = B{k};
for j=1:length(OutlineBoundaries)
OutlineBoundariesArr=OutlineBoundaries{j};
xv=OutlineBoundariesArr(:,1); yv=OutlineBoundariesArr(:,2);
xq=boundary(:,2); yq=boundary(:,1);
%only if condition is met should boundary of Sample be plotted here
if k>N %hole Boundaries
plot(boundary(:,2), boundary(:,1), '.g','MarkerSize',5);
else
plot(boundary(:,2), boundary(:,1), '.r','MarkerSize',5);
end
end
end
And the images:
'
For the 1st 2 images, the edges in the first image that correspond to the edges in the 2nd image should have their boundaries plotted, and any edges not matched should not be plotted. As seen in the 3rd image, the 2 large rectangular blobs in the 1st image match with the edges in the 2nd image so I want their boundaries plotted, which is why I boxxed them in green. The 2 small blobs in the 1st image don't match with the edges in the 2nd image, so I do NOT want their boundaries plotted, so I marked them with blue X's
I have the code setup, but I don't know what to write in line 24, which is why it says `%only if condition is met should boundary of Sample be plotted here`. How can I write this in Matlab?
  2 commentaires
Image Analyst
Image Analyst le 26 Fév 2019
I'm only seeing some thin lines in the second image (upper right), not any shapes. So I don't see how ANY of the 4 shapes in the first (upper left) image match those thin lines in the second image.
If you have two cell arrays and want to find matches, have you considered ismember()?
asdf
asdf le 26 Fév 2019
The thin lines in the 2nd image is intentional. I was hoping there was still a way to match those lines to the rectangular blobs in the 1st image, so the output is a plot of the boundaries of the rectangular blobs
Yes, I know about ismember.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by