Color profiling your own DSLR, redux
A newer rewitten version of this article is available here.
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 where-ever 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 semi-large 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 be sitting 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/weird results.
Now, make sure you have your camera set to RAW mode, 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/125s using ISO 100. To get a good shot, you should first check what your camera’s lightmeter thinks, keeping in mind that you probably need to “overexpose” a full stop or even a little more. I recommend setting your camera to full manual mode, and setting your aperture to a static value, for example f16, then take a shot with a 1/1000s exposure continuing to take shots each step down (1/800s, 1/640s, …). Keep doing this until you reach 1/10s exposure, or until your camera’s overexposure indicator is going totally bonkers. You can use your camera to see which shot will most likely give the best results, by viewing your last shot (having the overexpose-indicator on), which should be flash heavily. Now go back through your shots and the first shot that doesn’t blink will probably give you the best results. Don’t throw away the rest just yet, you won’t be sure which one you need until you check them with UFRaw.
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. If there are several patches which have identical D_RED/D_GREEN/D_BLUE values, you should pick the centremost patch with good 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 1,00; Linearity 0,00; 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.Then check if you are using digital linear clipping behavior and you have disabled restoration of details to prevent artifacts. You’ll notice the resultant image is quite dark, and it’s supposed to be that way, since it’s a linear representation of the image. Next, check if the white (leftmost) greyscale patch isn’t blown out using the color picker, you should see a value of less than 250 (though I’ve made my best profiles with the white leftmost patch at a value of 170-190). If it’s higher than 250, you should use another shot anyway. Same goes for the black (rightmost) greyscale patch, it should not be 0, but 5-15. Once that’s done, you should take the color picker and select the most neutral patch and do a custom white balance based on that patch. Now save the image to a TIFF file, preferably 16 bit.
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 target.tif’. This should get rid of any dust/speckles. You can vary the amount of -despeckle’s, but don’t go overboard. Always check your image for artifacts after despeckling them.
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 ArgyllCMS. Currently most Linux distributions don’t ship ArgyllCMS. I have a packaged version available in my Ubuntu repositories. Otherwise you’ll have to compile from source.
First you need to make sure you have access to your IT8 targets reference file (in my case R080505.txt). These reference files contain measurements of each patch’s exact color, so you need a reference file which is specific to your target. Also you’ll need to extract the it8.cht file from the ArgyllCMS source tarball. You can find the it8.cht file in the ref directory. Now everything is set, we can have ArgyllCMS do it’s magic:
# scanin -v -p -dip canon.tif it8.cht R080505.txt
# colprof -v -A “Canon” -M “Canon EOS 400D DIGITAL” -D “Canon EOS 400D (daylight)” -C “Copyright (c) 2008 Pascal de Bruijn. Some rights reserved.” -r 1 -q u -a S -n c canon
You might have noticed I’m using “Canon EOS 400D DIGITAL” as the (-M) model identifier. Since there is a seperate identifier for the (-A) manufacturer identifier it would seem more appropriate to list “EOS 400D” as the model. However, I prefer the use the exact strings the camera embeds in the EXIF data. There is currently no practical benefit to be gained. However in theory raw converters could potentially use these identifiers to match raw files to color profiles. Or at least bump matching profiles to the top of the list.
Another point of interest is the fact that ArgyllCMS can compensate for some perspective distortion. It will output a file named diag.tif which can you check if all the patches were properly detected, and no overlap occured.
Once this is all done, you should use the resulting profile using the gamma 1.0 and linearity 0.0 settings in UFRaw.
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 generic profile. Which we just tried to do. 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 separate profile for that.