How to use colormap

4 ビュー (過去 30 日間)
u-will-neva-no
u-will-neva-no 2012 年 11 月 3 日
Hi everyone. I want to color in the letter 'a' from an image full of different characters. I have two images, one with the characters without the letter 'a'(call this A) and one with only the letter 'a'(call this B). I want to set the image B to the color red using colormap but not sure how to use this function in this situation.
Thanks for reading.

採用された回答

Image Analyst
Image Analyst 2012 年 11 月 3 日
編集済み: Image Analyst 2012 年 11 月 3 日
Cast the images to single. Then subtract them and take the absolute value. Then threshold it
subtractedImage = abs(single(imageA) - single(imageAwithLetter));
binaryImage = subtractedImage > thresholdValue;
Then create image B:
imageB = rgb2gray(imageA); % or just imageA if imageA is already grayscale.
imageB(imageB == 255) = 254; % Set existing 255 to 254
imageB(binaryImage) = 255; % Set only the letter pixels to 255.
imshow(imageB);
myColormap = gray(256);
myColormap (256,:) = [1 0 0]; % 256 goes to pure red.
colormap(myColormap);
colorbar;
  1 件のコメント
u-will-neva-no
u-will-neva-no 2012 年 11 月 3 日
Nice one, thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by