Array function for ranges

1 vue (au cours des 30 derniers jours)
Azura Hashim
Azura Hashim le 7 Fév 2017
Modifié(e) : Jan le 15 Fév 2017
Hi,
I have a binary image in a matrix, call it binarymage. I then want to determine whether various areas in the image are white pixels only. The boundaries for the areas of interest are defined in as follows:
left=[1]; right=[11]; top=[5,6,7,8]; bottom=[15,16,17,18];
So in this example I have 4 boxes. How can get a result that tells me which boxes are white only. Example: whiteboxes=[1,0,1,0].
I think I need arrayfun but have not been successful after several attempts. Appreciate any help please. Thank you.

Réponse acceptée

Saurabh Gupta
Saurabh Gupta le 15 Fév 2017
You should be able to do it using a combination of not and any commands. One example could be as follows.
tempBox = binarymage(top(1):bottom(1), left(1):right(1));
whiteboxes(1) = not(any(tempBox(:)));

Plus de réponses (1)

Jan
Jan le 15 Fév 2017
Modifié(e) : Jan le 15 Fév 2017
A simple loop is a good point to start from:
left = 1;
right = 11;
top = [5,6,7,8];
bottom = [15,16,17,18];
whiteboxes = false(1, 4);
for k = 1:4
whiteboxes(k) = all(binarymage(left:right, top(k):bottom(k)));
end
What exactly is a "white" pixel? Does it have the value 1 or 0? Here I assume, that white mean 1. If 0 is meant, replace all() by ~any().

Catégories

En savoir plus sur Images 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