Reputation: 921
I have two images (slices) which were taken by two camera sensors to complete one image. However, due to some differences in sensors' performance, the colour/tones of them are different and I need to match them to make one unified image.
I used the HistogramMatcher
function that is included in Fiji (Image J) explained here to match the colours of the second image as the first one. It gives an acceptable result but still needs further processing.
So my question is, what are the best approaches to have a unified image. should I start with brightness, hue then saturation? Also is there other than 'HistogramMatcher' function to match colours?
below is an example of an image
Upvotes: 8
Views: 6136
Reputation: 207445
I split your image in two as follows, then used scikit-image
's histogram matching function:
#!/usr/bin/env python3
import numpy as np
from skimage.io import imread, imsave
from skimage import exposure
from skimage.transform import match_histograms
# Load left and right images
L = imread('rocksA.png')
R = imread('rocksB.png')
# Match using the right side as reference
matched = match_histograms(L, R, multichannel=True)
# Place side-by-side and save
result = np.hstack((matched,R))
imsave('result.png',result)
That gives this result:
Upvotes: 9
Reputation: 53081
For comparison, I have two Imagemagick bash shell scripts that transfer color from one image to another. (see http://www.fmwconcepts.com/imagemagick/index.php). One does color histogram matching and the other does color adjustment by matching mean and standard deviation (i.e. brightness and contrast).
I will use Mark Setchell's separated images.
Input
Histogram Matching:
histmatch -c rgb right.png left.png newleft_histmatch.png
convert newleft_histmatch.png right.png +append result_histmatch.png
Mean/Std Matching:
matchimage -c rgb left.png right.png newleft_matchimage.png
convert newleft_matchimage.png right.png +append result_matchimage.png
For a Python/OpenCV solution to color transfer using mean and standard deviation, see https://www.pyimagesearch.com/2014/06/30/super-fast-color-transfer-images/
Upvotes: 5