How to use colormap
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Image Analyst
le 3 Nov 2012
Modifié(e) : Image Analyst
le 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;
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Red dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!