Dcraw bad pixel mapping

From OSP Wiki

Jump to: navigation, search


This tutorial was last tested for UFRaw version 0.10.

Overview

Almost every digital camera has one or more untrustworthy pixels living in its sensor. A bad pixel typically registers brighter than those surrounding it; it frequently appears as pure white, or sometimes as one of the primary colors (red, green, blue). The effect of individual bad pixels may or may not be visible after your usual processing, depending on scaling, picture content and other factors. But when processing RAW photo files using UFRaw, it is possible to keep track of bad pixels and leave standing instructions for exactly those pixels to be ignored, and new values substituted that have been interpolated from surrounding pixels. Both UFRaw and its parent application, dcraw, support bad-pixel mapping. The feature is not mentioned in UFRaw's documentation.

Prerequisites

UFRaw, gimp-ufraw, or dcraw.

Steps

  1. Gather a list of your camera sensor's bad pixels.
    • Take a picture with the lens cap on, but with the shutter speed set fast enough that your camera's automatic noise reduction feature, if it has one, does not activate.
    • Process this black image normally and load it into an image editor or viewer, for example, GIMP.
    • Examine all of the image under high magnification. For each pixel that significantly deviates from fully black, determine its coordinates. If you are using GIMP, running your mouse over the pixel will cause its coordinates to appear in the image window's status bar, unless you have disabled the status bar.
  2. Create a text file where each line contains the coordinates of one of the bad pixels you found.
    • The format of one line is:
    x-coordinate y-coordinate timestamp
    • Leave the timestamp as 0 (zero) unless you know the pixel went bad at some particular point in time. In that case, supply an appropriate timestamp value in UNIX "seconds since 1970" format. This will be explained below.
    • Comments are allowed; start each with a pound sign ('#').
  3. Save the file in your user home directory, using .badpixels as the filename.

Timestamps

You might already know that a certain pixel in your camera sensor went bad at or around a particular date, or you might be able to determine this (if you think it's worth your trouble!) by looking through old image files. Once you have attached a date to the pixel in question, you can make it part of your ~/.badpixels file, but only after converting it to "seconds since 1970" format. One way to do this is by using the standard UNIX date tool. For example, convert July 19, 2007 this way:

 date -d 2007-07-19 +%s

This yields 1184821200, which is the value you would plug into the ~/.badpixels line corresponding to the pixel in question. The pixel's value will be considered bad only if the picture had been taken after the given date.

Example

An example ~/.badpixels file can be found here: http://www.cybercom.net/~dcoffin/dcraw/.badpixels

Personal tools