How to use colormap

1 次查看(过去 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;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by