필터 지우기
필터 지우기

How we can merge mask on RGB image

조회 수: 3 (최근 30일)
sakshi ahuja
sakshi ahuja 2018년 5월 24일
댓글: Image Analyst 2018년 5월 24일
Suppose I am having original image '1.jpg'- dimensions (605x700x3 uint8) and mask image 'D'-dimensions (255x255 unit 8). How do I showcase mask image on original image?

채택된 답변

Image Analyst
Image Analyst 2018년 5월 24일
I don't know what "showcase" means to you, but maybe you mean to mask the RGB image with the binary image. If so, do this:
% Mask the image using bsxfun() function to multiply the mask by each channel individually.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage));

추가 답변 (1개)

sakshi ahuja
sakshi ahuja 2018년 5월 24일
I tried this- maskedRgbImage = bsxfun(@times, img, cast(D, 'like', img)); but it is giving error- Error using bsxfun Non-singleton dimensions of the two input arrays must match each other. Final image has been attached.
  댓글 수: 1
Image Analyst
Image Analyst 2018년 5월 24일
D must be a 2-D logical image. img must be a 3-D RGB full color image. They both must have the same number of rows and columns. What does this show in the command window:
[rowsD, colsD, colorsD] = size(D) % No semicolon!
[rowsi, colsi, colorsi] = size(img) % No semicolon!

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by