Azzera filtri
Azzera filtri

Apply colormap to a library of iamges

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Simon Chan
Simon Chan il 7 Lug 2022
Something like this?
imshow(A,'Colormap',winter)
jlouise2022
jlouise2022 il 7 Lug 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.

Accedi per commentare.

Risposta accettata

jlouise2022
jlouise2022 il 7 Lug 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

Più risposte (0)

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by