Page 1 of 1
Generating and then applying color transformation matrices
Posted: 2014-05-28T20:00:52-07:00
by dada78641
Hi there. I've got a question, I'm not sure if Imagemagick is right for what I'm trying to do. Here's a simplified explanation of my problem:
Say I've got Photo A. And I've also got Photo B, which is the same as Photo A except it's had its colors/histogram modified in some way.
Now let's say I've also got Photo C, which is the same as Photo A except it's bigger has much nicer quality.
The question: how do I create Photo D, which is Photo C except with the same color transformations applied to it as Photo B?
In fact, I've got about 900 photos like this, and I want to run a script to examine them and then apply these modifications to all of them. (Looping through all of them is no problem, so if you could help me get it working with one example that'd be fine.) I was originally writing some programming code in PHP to create an image matrix based on examining the differences between Photo A and Photo B, but
it's kind of daunting and I'd prefer to use Imagemagick if it has these things already built in.
If you have any leads or ideas, that'd be great!

Re: Generating and then applying color transformation matric
Posted: 2014-05-28T20:23:07-07:00
by fmw42
What version of IM and what platform? Post one set of images A,B,C to dropbox.com (public folder) and put links to them here. Then we get a better idea of what you want to do and can experiment with your images.
If you want to capture the color transformation of an image and know how it was processed, you can use -hald to create the color processing and -hald-clut to apply it. If you do not know how to reproduce the color transformation, then histogram matching may work. If on unix (Linux, Mac OSX or Windows with Cygwin), you can try my script histmatch at the link below. Other approaches are possible if it is just contrast and brightness. But it would be best to see your example.
Re: Generating and then applying color transformation matric
Posted: 2014-05-28T21:32:32-07:00
by snibgo
I suspect the most effective way and general method for unknown processing is to automatically create a hald that gives the transformation from A to B. This should be fairly easy for the colours that are in A, and all other colours would be interpolated, perhaps using "-sparse-colour". I haven't done this, and it wouldn't be trivial as a hald is really a 3-D image, and IM only works in 2-D.
Meanwhile, simple solutions are possible when the transformations are simple, eg curve manipulations for R, G, B or tone, saturation, colour-shift, etc. As Fred says, put up samples.
Re: Generating and then applying color transformation matric
Posted: 2014-05-29T02:11:45-07:00
by dada78641
Hi there. Thanks for your replies, so quickly too!
Here's an example Photo A.
Here's an example Photo B (the difference is subtle).
My
photo C is also an example, as the real ones are much larger. But this is what I'm testing with for now.
All files can be found here.
What version of IM and what platform?
At the moment I'm using 6.8.8.10-1 (x86_64).
If you want to capture the color transformation of an image and know how it was processed, you can use -hald to create the color processing and -hald-clut to apply it. If you do not know how to reproduce the color transformation, then histogram matching may work. If on unix (Linux, Mac OSX or Windows with Cygwin), you can try my script histmatch at the link below. Other approaches are possible if it is just contrast and brightness. But it would be best to see your example.
I'm gonna give your script a try as soon as I can. I didn't do the color transformations myself so I don't know exactly what was done to the images, but I believe it's Photoshop's "Channel Mixer" plus maybe channel rotation (hue shift), plus changing the image's levels. So basically I doubt there's anything going on that can't be done by modifying histograms for each channel. Since each image has custom color modifications, I have to do this programmatically and based on an examination of each individual image rather than one common formula.
Re: Generating and then applying color transformation matric
Posted: 2014-05-29T09:48:22-07:00
by fmw42
try this. it seems to work pretty well
Code: Select all
histmatch -c rgb img_b.png img_c.png img_c2b_rgb.png
Re: Generating and then applying color transformation matric
Posted: 2014-05-31T17:54:03-07:00
by dada78641
Thanks so much! Sorry for replying so late, but it's been super busy so I haven't been able to return to this until now. But your script works perfectly for my purposes. Didn't expect it to be this easy...
