Assign black pixels to binary image

조회 수: 22 (최근 30일)
Abdul Salam
Abdul Salam 2019년 6월 28일
댓글: Abdul Salam 2019년 6월 29일
I have a binary image and i want to assign black pixels to the white segment and then mask it on original image. How can i do that?binary.JPG

채택된 답변

Image Analyst
Image Analyst 2019년 6월 29일
If "mask" is your binary image, and you want the white parts to be black (and the original pixels in the black areas of your binary image left unaltered) in your original grayscale or rgb image , called "yourImage", do this:
% Mask the image using bsxfun() function to multiply the mask by each channel individually.
maskedImage = bsxfun(@times, yourImage, cast(~mask, 'like', yourImage));
  댓글 수: 1
Abdul Salam
Abdul Salam 2019년 6월 29일
Thanks a lot. It realy worked for me. :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by