Matching Colors of Source Image to Target Image
5 views (last 30 days)
Show older comments
Hi. I want to match colors of source image to target image.
Source and reference images are identical with same resolution, aside from the color. (Actually, target image is a graded version of source image)
Here is the source image:

Here is the target image:

So far what I did is:
- -Converted source and target images to LAB color space
Now, I'm not sure how to proceed from here.
- -Shall I go with histogram matching in LAB (not sure how to do it)
- -Calculate deltaE between each pixel, calculate mean etc (also not sure how to do it)
- -Use any other Color Space such as LCH
Please help me regarding this...
2 Comments
Walter Roberson
on 26 Apr 2018
What do you mean by matching colors in this case? Are you looking for a linear transform in rgb, or in LAB? Looking for a curve of hue correction? A look up table of original and target colours?
Is it assumed that any given source color is always matched to the same target color?
Accepted Answer
Walter Roberson
on 27 Apr 2018
[old_colors, old_idx] = unique(reshape(Original_Image, [], 3), 'rows');
reshaped_new = reshape(New_Image, [], 3);
new_colors = reshaped_new(old_idx, :);
The lookup table is then that each row of old_colors is matched to the corresponding row of new_colors .
This assumes that any given source color is always matched to the same target color.
4 Comments
Walter Roberson
on 27 Apr 2018
Yes.
Note: rgb2lab() always produces double even for uint8 source, and lab2rgb() of that will produce double, with the round trip being equivalent to im2double(). Also I notice that the result of lab2rgb can be slightly negative due to round-off error such as for (0,242,65). However, if you im2uint8() the result of the round trip, then that will be identical to the original RGB.
More Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!