Extract the "overall colors" of an image to apply another?
Show older comments
I've been meaning to show my students a way to "borrow" the color palette of an image to apply to another?
Take the Mona Lisa, for example. It has its own "tones" and "mood". Suppose there was a way to load that image into Matlab and extract its "most vital" color characteristic? And then be able to "apply" this "personality" to any other existing image? I know, it's a crazy idea and I've been thinking what could possibly be the "linking mechanism" between the two images or between any two sets of images, for that matter, that would make this possible? Perhaps the "Brightness" levels? To me, it's clearly a problem of "mapping tones" between imiages but I have no idea where to start. But one thing is sure, the students would immediately understand the idea and, from a pedagogical point of view, it would go a long way towards building an "abstract" view of "image processing" which is what the class is about.
Accepted Answer
More Answers (2)
Richard Burnside
on 14 Jun 2023
Edited: Richard Burnside
on 14 Jun 2023
1 vote
The imread command will return the indexed image and the 256x3 colormap of the image:
[X,cmap] = imread('corn.tif');
You can work with that colormap to apply it to another image using the colormap command.
4 Comments
Roger Breton
on 14 Jun 2023
Roger Breton
on 14 Jun 2023
Edited: Walter Roberson
on 15 Jun 2023
Roger Breton
on 14 Jun 2023
Edited: Roger Breton
on 14 Jun 2023
Richard Burnside
on 14 Jun 2023
The answer supplied below by Image Analyst seems to have that process worked out. Pretty amazing results.
Image Analyst
on 14 Jun 2023
1 vote
The best algorithm I've seen for transferring the color gamut is Mark Grundland Color Histogram Specification by Histogram Warping

Sorry, I don't have code for that algorithm.
3 Comments
Roger Breton
on 14 Jun 2023
Image Analyst
on 14 Jun 2023
If youi can do it, let me know. And post it to the File Exchange. A couple of years ago I made a s tab at it and I got the first few steps done but then it got into some pretty sophisticated math that I didn't know how to translate into MATLAB so I gave it up.

Roger Breton
on 14 Jun 2023
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




