Coloring a grayscale image to two colors
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a grayscale image as shown below, I would like to color the dark layer to blue color and the white layer to red color and if possible I would like to change the background to any other color. Can anyone help me with this?
Thanks in advance.
0 Commenti
Risposte (1)
Image Analyst
il 26 Giu 2019
Determine the threshold between light and dark and have the colormap have one color up to that threshold and then the other color after that threshold. like
threshold = 128
cmap = repmat([0, 0, 1], 256, 1); % Initialize to blue
% Make red from 128 & brighter
for row = threshold : size(cmap, 1)
cmap(row, :) = [1,0,0];
end
Make the obvious adaptations for 3 or more color ranges.
0 Commenti
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!