White balance - color correction

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

White balance - color correction

Post by markmarques »

Hi all...
I know this a bit strange to ask but here I go ...
Here is my problem :
I have a SD14 which DCRAW with the "-d -6" option gives like this :

Image

(other dcraw options gives strange noisy results) ...
I know it is a bit bland but the info is inside .. :)

Now , here is the embedded JPEG iniside...
Image


How can I reach that saturation color ?
I have tried several approachs (levels, modulate ) etc, etc ...
But as stated in the "Usage site" the increase of saturation value will give a strange "cartoon lookalike" color.

Any ideas how to correct that saturation ?
in order to obtain that color ?

Could it be a simple matter of correcting the white balance ?

any ideas ?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: White balance - color correction

Post by el_supremo »

The dcraw documentation says that the -d option is "Document mode (no color, no interpolation)" which suggests that you should try the conversion without the -d option.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

Re: White balance - color correction

Post by markmarques »

After some trial and error the only mode that I get clean images from X3F files are with the "-d" option only ...
(talked about this with David Coffin some moths ago) ...

Even though in the dcraw docs reports as "-d" option being a complete no interpolation mode
the truth is that with the X3F file format the colour info is present although requiring some tuning ... :)

So the conventional options are off the table ...

The idea is to get a process where I can more or less auto magically put the image in a viewable state ...

Thanks in advance ..
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

Re: White balance - color correction

Post by markmarques »

After some tests I got the correct color ( by trial and error) and got the correct color by using "-modulate" operator....

Original image bad color : Image

Correct color by using -modulate 100,245,70

Image

But If I try with other images I get :

washed out color (original) Image

after applying the same options
Image

Any ideas of how to correct with a common command ?

I even thought of using the -recolor command but the info available is a bit sketchy ... :)

Any ideas ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: White balance - color correction

Post by snibgo »

Flowers are very bad subjects to use for calibrating colours, because they generally emit weird combinations of wavelengths (see "metamerism"). Cameras are generally okay for green vegetation, caucasian skin tones and blue skies. Better still, use a photographic colour chart (eg available from Kodak).
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: White balance - color correction

Post by fmw42 »

I know little about raw images or XCF format. But I am curious to understand why colors would be off so much that a pink flower would be orange.

Note -modulate can work in either HSB or HSL mode and differs depending upon which release you are using. See http://www.imagemagick.org/Usage/color/#modulate and esp the issues with near white at http://www.imagemagick.org/Usage/color/ ... colorspace
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

Re: White balance - color correction

Post by markmarques »

I do not have easy access to a colour chart ...
But If I understood correctly I can calibrate by using a real sky as reference...
As soon I have the time I will try that idea ...

Although a small question :
if I use HSL or HSB option is the the order of options kept ?
-modulate brightness , Saturation, Hue ...

I have found a small java tool X3FTool that partly does I need ...
But the "colour profile" change is fixed ...
I though that by changing some parameters I could have some finer control...

Thanks in advance...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: White balance - color correction

Post by fmw42 »

-modulate is always B/L,S,H

if using HSB, the first arg is B, if using HSL, the first arg is L. I recommend using HSB to avoid the white issue (because B/L with S work differently in HSL and HSB). That is the default in latter versions of IM. But earlier versions used HSL. In current versions, you can choose to use either (that is switch to HSL) if you want using the -set tag (as explained on the pages referenced earlier).
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

Re: White balance - color correction

Post by markmarques »

Hi ...
I have made the "blue sky" HUE test corrections
-modulate 100, 105, 115
but now although I have the correct sky color
all the "RED"s still need a change ...

At the end I suppose a global HUE change is off the question ...

My new idea: how can I shift the HUE in a single channel ? Is it possible ?

Can I "modulate" a a single channel ? or a color range ?

I tried some tests with "-recolor" matrix command but still with no success ...

The idea would be to change only the "RED" parts of the image ...

Any ideas ?
Last edited by markmarques on 2010-07-25T15:31:25-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: White balance - color correction

Post by fmw42 »

Hue makes no sense in a single channel. All individual channels are grayscale, thus Hue is undefined.

-recolor (now called -color-matrix) probably does not make sense for images in HSB or HSL due to the cyclic nature of Hue.

I believe that you need to come up with some look-up table method for calibrating your image's color (color curves for each channel). Again you probably want to use some color chart.

see
http://www.craigfineportraits.com/for_p ... dak_chart/
http://www.filmtools.com/grayscalandc.html
http://www.digital-photography.org/mcbe ... _Gray.html

and many others by searching Google for color chart.
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

Re: White balance - color correction

Post by markmarques »

After some tests I have figure it out
that the colour problem with the previous images is that it lacks a "colour profile" ...

Is there any way with image magick to apply or force a specific "colour profile" into an image ?

Is the "tint" operator a viable option ?

Any ideas ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: White balance - color correction

Post by fmw42 »

I am not an expert on profiles, but see -profile for adding (and removing profiles).

http://www.imagemagick.org/Usage/formats/#profiles

There are standard profiles, such as CMYK.icc and sRGB.icc.

-tint will only colorize a grayscale image in the midtone range, -colorize will colorize a grayscale image across the tonal range and +level-colors black,some color will help in the mid to highlight range

see
http://www.imagemagick.org/Usage/color/#tinting
http://www.imagemagick.org/Usage/color/#level-colors
http://www.imagemagick.org/Usage/color/#colorize

I suspect you really need to use -color-matrix in rgb to be able to fine tune what you want.

Note some profiles use a color-matrix approach and others use a lut approach (such as colorizing a gradient and applying with -clut). For the lut approach see http://www.imagemagick.org/Usage/color/#color_lut and for the color-matrix approach see http://www.imagemagick.org/Usage/color/#recolor

If you can adjust your image as needed in Photoshop, then you could create a hald image, apply the same processing to it in Photoshop, then use that result with -hald-clut to apply it to any image in IM. see http://www.imagemagick.org/Usage/color/#hald-clut and http://www.imagemagick.org/Usage/color/#hald_limits


This is an interesting page regarding lut profiles and a profile editor. http://eddiem.com/photo/labwarp/labwarp.html
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: White balance - color correction

Post by fmw42 »

markmarques wrote:After some tests I got the correct color ( by trial and error) and got the correct color by using "-modulate" operator....

Original image bad color : Image

Correct color by using -modulate 100,245,70

Image

But If I try with other images I get :

washed out color (original) Image

after applying the same options
Image

Are these the original images? Or have they been processed from raw to jpg by some technique? Have you lost information from your raw files?

Can you post the raw files or use exiftool on it to report what information you might have there?

Any ideas of how to correct with a common command ?

I even thought of using the -recolor command but the info available is a bit sketchy ... :)

Any ideas ?
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

Re: White balance - color correction

Post by markmarques »

The images are JPEGs (resized ) from RAW X3F files ( SD14 Foveon sensor) started with DCRAW -D option ...
I know that DCRAW -D option is for a complete RAW file ( no interpolation, no color) ...
BUT with Foveon data it gives a clean full image (unsaturared) ...

So my main problem is the lack of the profile information ...
The 2 images were the Embedded (resize again) JPEG "thumbnail" made by the camera and extracted also with DCRAW ...

Thanks for the info regarding the profiles ....
I will try some of the -profile options...
and return with some info ... :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: White balance - color correction

Post by fmw42 »

thumbnails can remove header-like information, so you may have lost any imbedded profiles. Have you looked at the verbose info from your original size JPGs? try exiftool also. Seems to me something is wrong with your camera or setup for processing as I cannot believe that you will be so far off in color.
Post Reply