Matlab - How to mask a 3-D image using a binary image

后端 未结 3 1834
感动是毒
感动是毒 2020-12-20 06:21

I have an image with red, green, blue channel and a binary version of the image.

What I want to do is concatenate those 2 images so that the binary image works as th

3条回答
  •  情书的邮戳
    2020-12-20 06:54

    If you have a 3-D image I and a binary mask M, you can mask the irrelevant bits to zero either by multiplying the image by the mask:

    I = bsxfun(@times, I, M);    
    

    or by logical indexing:

    I(~mask(:, :, ones(1, size(I, 3)))) = 0;
    

提交回复
热议问题