Color profiling your own DSLR

This post has been obsoleted by a newer post.

Modern digital camera’s tend to produce beautiful images. But as you might have guessed this is because of a lot of post processing done by the camera, after the image is captured by it’s sensor.

Image sensors (often called a CCD or CMOS sensor), don’t capture images in a way a normal computer can understand it (RGB), instead they use a so called Bayer pattern. This pattern can be converted to RGB using a demosaicing algorithm.These algorithms only convert the image representation, they do not generally affect color. When they do it’s generally considered an artifact.

Even then, the camera’s isn’t finished. The colors an image sensors sees does not by definition match what we see. The discrepancy can be quite significant. This means the colors have to be corrected somehow. When the digital camera itself corrects color, it’s usually a vendor proprietary technology. But in the end it’s basically the same general thought, some colors need to be emphasized, others should be reduced. Almost fifteen years ago, vendors realized that these technologies could be generesized, into what we today know as ICC profiles.

In case of a Digital SLR camera, it’s possible to have Raw (usually 12 bit) output, instead of preprocessed (8 bit) JPEGs. This means the camera does no correction whatsoever. This implies your computer still has to demosaic the image and everything. This has several advantages, first your computer has a lot more computing power, allowing you to apply more advanced demosaicing algorithms. It also gives you much more control about your colors.

Some vendors may publish ICC profiles for their DSLR camera’s. Other may not. In my case, Canon does have ICC profiles, which can be obtained like so. However when used with UFRaw, they don’t seem to work that well, colors still seem off. It’s very possible Canon still uses some secret sauce in their profiles, which only Canon software understands, making them virtually useless to everybody else.

But there is another option, if you’re willing to invest some time and money. You can profile your own DSLR camera using a so-called IT8 target. IT8 target’s can be obtained from several vendors including Kodak. However these can be quite expensive, with price point near 75 EUR. However they can be obtained more economically from Wolf Faust. His C1 camera target can be obtained for a mere 25 EUR, and has worked very well for me.

Once you have your target, the basic procedure is reasonably straight forward. It does however require some precision and care. First you’ll photograph the target, then you’ll run some software on the resulting image to analyse the difference in color, the software then produces a standard ICC profile containing the needed color corrections.

Photographing the target is less trivial then it may sound at first. For best results you should do this only when the sun is highest in the sky. This means you only have a one hour window every day. You can lookup the sun’s position whereever you’re on the earth here. When taking the picture there should be no clouds obscuring the sun, if there are clouds, considering waiting a day or so, to try again. You should basically be able to feel the warmth of the sun in your back while taking the shot, if this isn’t the case, you may get suboptimal results.

Now you know when to photograph the target, we still need to deal with how to photograph the target. You should look for a semilarge open spot, with no shadows. Take a chair without armrests (armrests can cause shadows on the target) and make sure the shadow of the chair itself extendeds perfectly straight behind the chair. So if you would sit down on it, you’d be looking straight into the sun. Next position the target on the chair, at about a 45 degree angle to the sun. The target should be evenly lit, if not you may get suboptimal results.

Now, make sure you have your camera set to Raw, and take a photo of the target from 1-2 meters away, preferably using a “standard” lens. The target should fill about 75% of your photo. I took the shot at 70mm f16 1/100s. You should probably trust your camera’s built-in lightmeter on this. After taking the shot, check the histogram, it should be somewhat level. The overexposure indicator should not be blinking. If it does, take another shot using exposure compensation.

Before we can go any further, you should check which patch on the target is most neutral (in my case greyscale six). Your IT8 target came with a CD, containing the measurements of the target. These measurement are in text format. Look for which patch has the closest D_RED/D_GREEN/D_BLUE values. You’ll be using this patch for whitebalancing.

Once you’ve taken a proper shot of the target and know which patch is most neutral you can start processing the target’s photo using UFRaw. Once you have loaded the target’s Raw photo into UFRaw, you should make sure the following settings are set: Exposure 0,0; Saturation 1,0; Contrast 1,0; Gamma 0,45; Linearity 0,10; and all the curves should be linear. Also check the camera input profile is set to “No profile”, and all other profiles are set to “sRGB” with a “Absolute Colorimetric” rendering intent. Once this has been done, you should take the color picker and select the most neutral patch and do a custom white balance based on that patch. Next take the color picker and select the leftmost greyscale patch, and adjust exposure until it’s RGB values are in the 210-230 range. Then select the rightmost greyscale patch (using the color picker), and adjust liniearity until it’s RGB values are in the 10-20 range. Now save the image to a TIFF file, preferably 16 bit, but 8 bit should get you pretty decent results as well.

I had some trouble getting a “clean” shot of the target, I always had some dust here or there on the target. This can negatively influence your profile in the end. So I postprocessed my target using GraphicsMagick: ‘gm mogrify -despeckle -despeckle -despeckle target.tif’. This should get rid of any dust/speckles. You can vary the amount of -despeckle’s, but don’t go overboard.

Now we’ve completed all our preperations we can finally get started with the actual profiling itself. To do this you’ll need to install LProf. Currently most Linux distributions ship an ancient version of LProf, which does work. But I prefer a CVS checkout. So if you can’t find some of the described options, it’s probably because you’re using an older version of LProf than me.

First you’ll need to install the reference file (in my case R080505.txt) for your specific IT8 target, you’ve used this file earlier to lookup which patch was most neutral. This file contains measurements of each patch’ exact color. After installing this reference file, you should be able to select your target (in my case “DIN A4 R080505 white backing Wolf Faust”). Then load the previously prepared TIFF file. LProf doesn’t automatically detect the patch locations, you’ll have to give LProf a hand. Select the four corners of the outer black border. Once you’ve clicked the fourth corner, you should see LProf project a grid of frame over your target. As you’ll notice LProf can compensate for a little perspective distortion. Make sure that each frame only covers a single colored patch. A frame should always have some clearance. Using LProf CVS you can vary the frame size using the safe frame setting, about 40% works well for me.

Now LProf is ready to generate your profile, you should check some settings first. First go to set profile identification and file name. There you can speficy the filename of the to be generated ICC profile. As well as profile metadata, like description “Canon EOS 400D (daylight)”; model “EOS 400D”; manufacturer “Canon” and copyright. Please always specify some form of copyright, even if it’s public domain. If that’s all set you should check your profile generation parameters. If you’re using a 8 bit TIFF file you should probably stick to a CLUT resolution of 17 (small), if you’re using a 16 bit TIFF file you could select 21 (large). I personally recommend against using any smoothing, so set that to a manual smoothness of 0. I usually set profile verbosity to store anything. For white point handling you’re usually fine with Dmin target patch, you could try diffuse reflector/illuminant color as well, see how that works for you. I usually stick to Dmin target patch. I also never enable luminance scaling, mainly because I have no clue what it does. I generally leave perception intent settings alone as well. Leave them be at “ISO-3664 P2”.

Now take a deep breath and hit create profile. LProf will be doing some math, and before you know it, you’ll have a custom color profile for your DSLR camera. Now you can use the generated profile with UFRaw. You should use it with the same gamma (0,45) and linearity (in my case 0,05) you had set, before saving the target in UFRaw for creating the profile.

Another cool feature in LProf is the profile checker. It can give you lots of information about ICC profiles, including a cool CIE chromacity diagram. The profile checker has significantly improved in LProf CVS. In my case I can clearly see that my EOS 400D needs the biggest corrections in the greens.

Generally ICC profiles are intented only to be used with very specific setups. A specific camera using a specific lens shooting under specific controlled lighting. This basically means, you’d have to profile each possible setup, to get “optimal” results. However, daylight is considered the reference light source, the sun’s light has the broadest spectrum, and it’s the only source (not really counting Xenon Arc lamps) that could be used to generate a more or less representative profile. Which we just did. So you should be able to apply the profile you just made to most photos, not just photos taken in daylight. Still if you have your own studio with controlled lighting, you should consider creating a seperate profile for that.

I couldn’t have written the above tutorial without the LProf documentation, and Elle Stone.