Apply colormap to a library of iamges

1 vue (au cours des 30 derniers jours)
jlouise2022
jlouise2022 le 7 Juil 2022
Is there a way to apply a specific colormap to a set of images?
I have lots of greyscale images (92) in my directory. Have tried lots of things but can't seem to apply one map to the entire set.
I can only achieve it by doing them separately. e.g.:
A = imread("1698_gs_histeq.jpg");
imshow(A)
colormap ("winter")
Thanks!
  2 commentaires
Simon Chan
Simon Chan le 7 Juil 2022
Something like this?
imshow(A,'Colormap',winter)
jlouise2022
jlouise2022 le 7 Juil 2022
I can only get that to work with a single image, not the entire set. I'm trying to write a function/for loop so that the colormap is applied to all 92 and they are saved in the directory.

Connectez-vous pour commenter.

Réponse acceptée

jlouise2022
jlouise2022 le 7 Juil 2022
Nevermind, fixed it.
If anyone has the same issue, here is my code:
for k = 1:numel(filenames)
filename = filenames(k).name;
equalHist = imread(filename);
[~,name,~] = fileparts(filename);
gsFilename = sprintf('%s_autumn.jpg', name);
imwrite(equalHist, colormap(autumn), gsFilename);
end

Plus de réponses (0)

Catégories

En savoir plus sur Blue dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by