How to use 2D logical mask on an image without for loop?
Show older comments
I have two image matrices A and B with size 512 x 512 x 3, and a logical mask of size 512 x 512. For each position with true value in the mask, I want to set A's value to B's. Currently I only know the for loop solution:
for y = 1 : height
for x = 1 : width
if mask(y,x)
A(y,x,:) = B(y,x,:)
end
end
end
Is there a way to avoid the for loop?
Answers (1)
Categories
Find more on Deblurring in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!