Page 1 of 1

Fred's ImageMagick Scripts : COLOR BALANCE

Posted: 2013-11-06T11:50:53-07:00
by badabou
Hi,

The script "colorbalance" created by Fred seems to have a problem when a value other than "all" is used for the "region" parameter.

Here is an example:

Code: Select all

./colorbalance -c red -a 100 -r midtones star.jpg out.jpg
Result image:
Image

The same parameters but with Photoshop:
Image

Do you have any idea? If Fred goes here?

Thank's

Re: Fred's ImageMagick Scripts : COLOR BALANCE

Posted: 2013-11-06T12:12:06-07:00
by snibgo
Fred probably will come along, but he may want to try with your original image.

Re: Fred's ImageMagick Scripts : COLOR BALANCE

Posted: 2013-11-06T12:45:12-07:00
by badabou
That's right snibgo, here's the original image:

Image

Re: Fred's ImageMagick Scripts : COLOR BALANCE

Posted: 2013-11-06T13:00:24-07:00
by fmw42
Can you reproduce my examples?

I will look into seeing if the script has problems.

But note, my colorbalance is not the same technique as used in Photoshop and likely will not work comparably.

What version of IM are you using and on what platform?

Re: Fred's ImageMagick Scripts : COLOR BALANCE

Posted: 2013-11-06T22:39:39-07:00
by fmw42
My colorbalance script is working as programmed. But as I said above it is not the same algorithm as in PS.

Closest I can come is only approximate with

colorbalance -c red -a 25 968678original.jpg result1.jpg

or

colorbalance -c red -a 75 -r m -m 50 -t 200 968678original.jpg result2.jpg

Re: Fred's ImageMagick Scripts : COLOR BALANCE

Posted: 2013-11-07T01:26:38-07:00
by badabou
Fred, I looked at the source of the script and the variable $mid (-m) seems to be used anywhere. Is this normal ?

Thus, whatever its value, it has no impact on the final result.

Alternatively, is it possible to have a general method for the script is like Photoshop?

Thank's

Re: Fred's ImageMagick Scripts : COLOR BALANCE

Posted: 2013-11-07T10:59:44-07:00
by fmw42
badabou wrote:Fred, I looked at the source of the script and the variable $mid (-m) seems to be used anywhere. Is this normal ?

Thus, whatever its value, it has no impact on the final result.

Alternatively, is it possible to have a general method for the script is like Photoshop?

Thank's

-r midtones is the argument and it is trapped at the bottom of the script at line 329 with

if [ "$region" = "midtones" ]; then
...

The argument mid is used to set the middle of the midtones region and defaults to the mean of the image. But it is only computed when region is not all (such as for midtones, shadows and highlights). See line 319

You are right about it not being used (unless it takes the default value). That is a mistake. I need to have it compute the low and high values (if not specified) from the mid value when the mid value is provided and not the default value. Give me a little time to fix this. I will get back shortly.

It may be possible to create something like PS colorbalance, but I do not know what algorithm is being used. It would take quite some effort of trial and error to try to figure out what they are doing and I may not be successful in the end.

I will put it on my to do list, but I have no idea when I will be able to get back to it.

Re: Fred's ImageMagick Scripts : COLOR BALANCE

Posted: 2013-11-07T12:12:32-07:00
by fmw42
I have fixed the issue with the script and done some further testing on your image.

Try adjusting the -a value and especially the -f value. The midtone region needs to be wider than 1 standard deviation. A value of 3 (std) is much better and closer to the PS result though not a perfect match. So try

Code: Select all

colorbalance -c red -a 25 -r m -f 3 968678original.jpg show:
and play around with those values

Re: Fred's ImageMagick Scripts : COLOR BALANCE

Posted: 2013-11-09T17:24:30-07:00
by fmw42
Using tint for a midtone color adjustment gets pretty close to your result from PS


convert 968678original.jpg \
\( +clone -level 0x99% -fill red -tint 25 -alpha set -channel a -evaluate set 100% +channel \) \
-compose over -composite -modulate 100,90,100 result.jpg

You can set the opacity lower to simulate less colorbalance in PS