Timtam
Timtam

Reputation: 223

test over 3rd dimension MATLAB

I have a 3d array. 1st dim is xcoordinate of pixel

2nd dimension is y - coordinate of pixel. 3rd coordinate is time (or could be though of as the frame number).

I want to do a test to see if any pixel is equal to zero for every single frame (along 3rd dimension).

How would I write this test?

I need returned the pixels which are ALWAYS true!!!

Upvotes: 0

Views: 211

Answers (1)

triazotan
triazotan

Reputation: 2232

Rather than all you could use any. If I understand you correctly, the code would go something like this for a single "pixel"

any(A(x,y,:))

where A is the 3d matrix. If the result is 1, then the given pixel does have a non-zero value for at least one frame, and 0 otherwise.

Upvotes: 1

Related Questions