フィルターのクリア

How to retrieval back the color in particular area from original image?

1 回表示 (過去 30 日間)
Mei Synn Tan
Mei Synn Tan 2017 年 3 月 17 日
編集済み: Mei Synn Tan 2017 年 3 月 20 日
13100.jpg
colorImage = imread('13100.jpg');
grayImage = rgb2gray(colorImage);
mserRegions = detectMSERFeatures(grayImage);
mserRegionsPixels = vertcat(cell2mat(mserRegions.PixelList));
mserMask = false(size(grayImage));
ind = sub2ind(size(mserMask), mserRegionsPixels(:,2), mserRegionsPixels(:,1));
mserMask(ind) = true;
figure;imshow(mserMask);
MSER mask
How to retrieve back the original color from 13100.jpg and paste into MSER mask (white area)?

採用された回答

Guillaume
Guillaume 2017 年 3 月 17 日
Much simpler:
maskedimage = immultiply(colorImage, repmat(mserMask, [1, 1, size(colorImage, 3)]));
imshow(maskedimage);
Note that if you just want to see if your mask is correct
imshowpair(colorImage, mserMask, 'blend');
may be more useful.
  3 件のコメント
Guillaume
Guillaume 2017 年 3 月 18 日
That's because you're only setting the red plane to 255, leaving the green and blue plane.
whiteMaskedImage(repmat(~mserMask, 1, 1, 3)) = 255;
would fix this.
Mei Synn Tan
Mei Synn Tan 2017 年 3 月 20 日
編集済み: Mei Synn Tan 2017 年 3 月 20 日
Dear Guillaume, It's work and thanks for helping. Have a nice day

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2017 年 3 月 17 日
Try bsxfun():
% Mask the image using bsxfun() function
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage));
  1 件のコメント
Mei Synn Tan
Mei Synn Tan 2017 年 3 月 18 日
編集済み: Mei Synn Tan 2017 年 3 月 18 日
Good afternoon to KSSV, Guillaume and Image Analyst, Thanks for helping. Both immultiply & bsxfun function can be use and get the correct result. Thanks and have a nice day.
How to change or convert the black area to white color?

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

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by