Hi,
I would like to match colours from two images, both represent the same object (geology outcrop) but they are taken from different angles and on first look they are totally different. Do you know if ImageMagick can fix it?
I don’t want to change size or image format I just want to received images with similar colours in the end (I would like to use them to texturing in 3d model without colour discrepancies in results).
Here is two sample images.
https://drive.google.com/folderview?id= ... sp=sharing
I am working on windows 10, and I have installed ImageMagick-6.9.2-6-Q16-x64-static.exe
Any help is much appreciate.
Magda
match colours from two images
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: match colours from two images
I can see by eye that the right side of a.jpg matches with the central part of b.jpg. What result do you want? What do you mean by "fix it"?
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: match colours from two images
I think the OP wants something like my histmatch script or -remap. My histmatch does not do a good job because the histogram is limited to 256 colors. I suspect that remap may be the same at 256 colors and so might need more than 256 colors also. One would have to limit the number of colors in a.jpg (-colors), get the colormap, create a new colormap image, then use that with -remap. See http://www.imagemagick.org/Usage/quantize/#remap.
Since the OP is on Windows, see snibgo's web site, perhaps he as something similar, but with a longer histogram.
Since the OP is on Windows, see snibgo's web site, perhaps he as something similar, but with a longer histogram.
Re: match colours from two images
snibgo, you have right, between images I try to keep some overlaps (about 20%). By saying 'fix it' I mean create two images with correspondence colour (i.e. grass/rock on image 'a' have same colour like grass/rock on image 'b').
fmw42 I already try to use histmatch script, resault you can see at https://drive.google.com/drive/folders/ ... jNoamVpSkE 'ab_histmatch.jpg'. They are not perfect, images have very intensive colours.
my command: $ histmatch -c RGB -L a.jpg b.jpg ab_histmach.jpg
Can you describe a bit more your idea? I should limit number of colours to 256 on image 'a' and 'b' and then use -remap? What will be the final quality of image, same as original or less?
fmw42 I already try to use histmatch script, resault you can see at https://drive.google.com/drive/folders/ ... jNoamVpSkE 'ab_histmatch.jpg'. They are not perfect, images have very intensive colours.
my command: $ histmatch -c RGB -L a.jpg b.jpg ab_histmach.jpg
Can you describe a bit more your idea? I should limit number of colours to 256 on image 'a' and 'b' and then use -remap? What will be the final quality of image, same as original or less?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: match colours from two images
It is not a very easy thing to do. You can use something like the following in Unix (sorry I do not know how to do it in windows)Magda_Ch wrote:
Can you describe a bit more your idea? I should limit number of colours to 256 on image 'a' and 'b' and then use -remap? What will be the final quality of image, same as original or less?
Code: Select all
# get list of 2048 hex colors and put into an array
colorArr=(`convert a.jpg +dither -colors 2048 -unique-colors -depth 8 txt:- |\
tail -n +2 | sed -n 's/^.*\(#.*\) .*$/\1/p'`)
numcolors=${#colorArr[*]}
# make 1D color image (lut) of all the hex colors
str=""
for ((i=0; i<numcolors; i++)); do
color=${colorArr[$i]}
pixel="xc:'$color'"
str="$str $pixel"
done
eval 'convert '$str' +append lut.png'
# apply the lut to b.jpg to make it look more like a.jpg
convert b.jpg -remap lut.png b2.jpg
I think my histmatch script might work much better if the histogram allowed more colors. But right now it is limited to 256 colors.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: match colours from two images
With my Windows BAT script, which uses process modules:
The result resized down is:
The magenta etc will be from colours in b that are outside the gamut of a. Something could probably be done about that.
I have load of scripts that might find features that align.
Code: Select all
%PICTBAT%matchHisto b.jpg a.jpg rocks_ba.jpg
The magenta etc will be from colours in b that are outside the gamut of a. Something could probably be done about that.
I have load of scripts that might find features that align.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: match colours from two images
snibgo: Is your script processing each channel separately or using intensity like channels to process all channels together? If the former, does your script allow you to do the latter?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: match colours from two images
My script converts each input to Lab, runs the process module which processes each channel independently, and converts back to sRGB. It runs this command:
Code: Select all
%IMDEV%convert ^
%INFILE% ^
-colorspace Lab ^
( -clone 0 ^
-process 'mkhisto cumul norm' ^
) ^
( %2 ^
-colorspace Lab ^
-process 'mkhisto cumul norm' ^
-process 'mkhisto cumul norm' ^
) ^
( -clone 1-2 -clut ) ^
-delete 1-2 ^
-clut ^
-colorspace sRGB ^
%OUTFILE%
snibgo's IM pages: im.snibgo.com