how to use a binary mask as a "stencil" for a grayscale image?

8 ビュー (過去 30 日間)
Naim
Naim 2017 年 6 月 22 日
コメント済み: Naim 2017 年 6 月 22 日
Hey everyone,
I have a binary mask (first attached image) that I want to use to trace-out the image of a gray-scale picture (second attacked image) and create another image in that manner.
I tried the simple AND operation, but the newly created image is a binary, not grayscale. I want to use the mask to crop out the image, without changing anything else.
Thanks in advance for any tips!

採用された回答

Image Analyst
Image Analyst 2017 年 6 月 22 日
Simply use the inverse of the mask to set those pixels to zero.
imageCopy = grayImage; % Make a copy so you don't destroy the original.
imageCopy(~mask) = 0; % Set black areas to black, leaving gray areas intact.
  1 件のコメント
Naim
Naim 2017 年 6 月 22 日
simple, obvious, and worked just how I wanted it to!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by