Effacer les filtres
Effacer les filtres

How to intersect 6 binary images?

2 vues (au cours des 30 derniers jours)
Ivan Shorokhov
Ivan Shorokhov le 15 Juil 2015
Commenté : Ivan Shorokhov le 15 Juil 2015
Given: I have 6 binary image:
Want: I want to intersect those 6 images to get the objects which will appear in all images.
Currently done:
I can do it manually, such as:
AllImages = cont{1} & cont{2} & cont{3} & cont{4} & cont{5} & cont{6};figure; imshow(inBothImages);
Needed: I'm wondering how to make a loop for it?
Such as:
if length(num)>2
for m = 2:length(num(num>0))
AllImages = cont{num(1)} & cont{num(m)}
end
end
But it did't work.
[ACKNOWLEDGMENTS]
Thank you Guillaume!
[MATLAB version]
R2014a

Réponse acceptée

Guillaume
Guillaume le 15 Juil 2015
The simplest way is to concatenate all your images in a higher dimension and simply use all in that higher dimension.
If your images are 2d:
AllImages = all(cat(3, cont{:}), 3); %that's it all done.
or for a generic cell array of Nd images:
higherdim = ndims(cont{1}) + 1;
AllImages = all(cat(higherdim, cont{:}), higherdim);
  1 commentaire
Ivan Shorokhov
Ivan Shorokhov le 15 Juil 2015
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by