Clear Filters
Clear Filters

Apply colormap to a library of iamges

1 view (last 30 days)
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 Comments
Simon Chan
Simon Chan on 7 Jul 2022
Something like this?
imshow(A,'Colormap',winter)
jlouise2022
jlouise2022 on 7 Jul 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.

Sign in to comment.

Accepted Answer

jlouise2022
jlouise2022 on 7 Jul 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

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!