How to use colormap

6 visualizzazioni (ultimi 30 giorni)
u-will-neva-no
u-will-neva-no il 3 Nov 2012
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.

Risposta accettata

Image Analyst
Image Analyst il 3 Nov 2012
Modificato: Image Analyst il 3 Nov 2012
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;

Più risposte (0)

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by