I have a 1024×1024 image matrix A and 256×156 image matrix B. I want to set all of pixels to zero in A except for pixels where B = 1.
If B has the same size, I can just do
A(B~=1)=0;
But since B is of smaller size, I want to find complement of B in A. How can I do this?
You could zero-fill B up to the same size
B(1024,1024) = 0;
And then your statement would work.