Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456 Decoding raw digital photos in LinuxBack to Dave Coffin's Home Page
Welcome! If you are wondering how to connect your digital
camera and download images to a Linux PC, go to the
gPhoto homepage.
My software is for processing those images after
downloading them.
If you're downloading JPEG files, you don't need my software
at all. The image has already been processed inside the
camera. Almost all digital cameras made since 1997 produce
JPEG images, so why would you want to do it any other way?
Well, despite the convenience and ubiquity of JPEG, there are
some disadvantages. JPEG is a lossy format -- to fit a big
image into a small file, a lot of information is thrown away.
That's why midrange and high-end digital cameras offer an
alternative: Raw, unprocessed CCD data files, for which the
camera manufacturer provides special decoding software.
Of course this software is for Windows and Macintosh only,
with no source code. So it's useless to users of other
operating systems, programmers hoping to design a better
interpolation algorithm, and historians not yet born in an
era when the only Windows machines will be in museums.
So here is my mission: Write and maintain an ANSI C program
that decodes any raw image from any digital camera on any
computer running any operating system.
That program is called dcraw
(pronounced "dee-see-raw"),
and it's become a standard tool within and without the
Open Source world. It's small (about 8000 lines), portable
(standard C libraries only), free (both "gratis" and "libre"),
and when used skillfully, produces
better
quality
output
than the tools provided by the camera vendor.
Here's my resume.
I do freelance consulting related to dcraw, and I'm also
available for full-time software work in the Northeast USA.
I can be reached by sending e-mail to cybercom dot net with
the username "dcoffin".
Unless otherwise noted in the source code, these programs are free
for all uses, although I would like to receive credit for them.
Donations are welcome too, if you're making money from my code.
Note to Linux distributors: The only executable files that
should be installed by a dcraw package are "dcraw", "clean_crw",
and maybe "fuji_green", "fujiturn", and "fujiturn16". My shell
scripts are dangerous and should only be installed in a "doc"
directory without execute permission.
dcraw.c -- decodes raw photos, extracts
thumbnails, and displays metadata Supports 321 cameras at last count.
Compile with "gcc -o dcraw -O4 dcraw.c -lm -ljpeg -llcms"
or "gcc -o dcraw -O4 dcraw.c -lm -DNO_JPEG -DNO_LCMS".
Run with no arguments to see a usage message.
Don't complain that 16-bit output is too dark -- read the FAQ!
UNIX manpage for dcraw This is dcraw's official user documentation, updated in
lockstep with the source code.
rawphoto.c -- basic plugin for GIMP 1.2 & 2.0 After installing "dcraw",
do "gimptool --install rawphoto.c".
My plugin provides a simple dialog box for loading raw
files into the Gimp.
Udi Fuchs
and
Joseph Heled
have written much nicer plugins, with live preview, histograms,
and color curves.
clean_crw.c -- clean Canon CRW files Recovered or undeleted CRW files often have junk appended
to them that makes them unreadable. This program safely cleans
CRW files.
To build a unilingual, self-contained DCRAW.EXE for DOS/Windows,
use a source file from this directory instead.
To add another language, send me translations of
this manpage and
this message table
in UTF-8 encoding.
Translate only from my original English and Esperanto texts --
other languages may contain factual errors invisible to me.
Do not translate "Cannot do X" as "It is impossible to do X".
Dcraw is not perfect, so if it cannot do something, that does
not mean that the task is impossible. Computers must never use
the pronoun "I", so write "dcraw cannot do X".
When in doubt, translate everything. I proofread these texts
before releasing them, and it's much easier for me to correct
over-translation than under-translation.
Dcraw decodes raw photos, not raw files.
No digital camera generates raw files in normal usage,
there's always a header with useful metadata.
(For abnormal usage, see CHDK and DIAG RAW below)
"raw" is an English word, not an acronym or file format.
"raw photo" should be translated with the same adjective that
you would use for "crude oil" or "raw materials".
There are dozens of raw photo formats: CRW, CR2, MRW, NEF,
RAF, etc. "RAW Format" does not exist; it is an illusion
created by dcraw's ability to read all raw formats.
Dcraw has made it far easier for developers to support a wide
range of digital cameras in their applications. They can call
dcraw from a graphical interface, paste pieces of dcraw.c into
their code, or just use dcraw.c as the documentation that camera
makers refuse to provide:
If you're familiar with the DOS command line but don't know C,
you can install this
free C compiler for Windows and compile dcraw.c quite easily.
Why does dcraw say "Out of memory" in Windows Vista?
This is an arbitrary limitation of Windows Vista that will be
fixed in Service Pack 1.
Thomas Nicely (of Pentium FDIV fame) has a
page describing the problem.
At the moment, the only workaround is to build dcraw.exe with a
Microsoft compiler instead of a GNU compiler.
How can I read the EXIF data (shutter speed, aperture, etc.)?
Phil Harvey's ExifTool provides a unified Perl-based EXIF
reader (and editor!) for all cameras and file formats.
"dcraw -i -v" is much faster, but provides less information.
Why are dcraw output images larger than camera JPEGs?
Any algorithm that combines each pixel with its neighbors is
going to have problems near the edges. C code is cheap, so dcraw
applies a different algorithm to edge pixels. Hardware logic is
expensive, so cameras crop off the edge pixels after processing.
I shot a raw photo with no light. Why does it appear
all noisy, when it should be solid black?
No matter how dark an image is, dcraw's auto-exposure stretches
it so that one percent of its pixels appear white. The "-W" option
avoids this behavior.
I bracket plus/minus two stops, but all five shots look
almost the same in dcraw. Why?
See the previous question.
Why is 16-bit output dark / unreadable?
If you want pretty pictures straight out of dcraw, stay with
8-bit output. 16-bit linear output is the best raw material
for professional image editors such as
Photoshop and
CinePaint,
but it's no good for most image viewers.
What does the "-f" (four color RGB) option do?
If you see patterns like this
or this in your output images, first
try "dcraw -a". If these patterns persist, use "dcraw -f" to
get rid of them.
Could you please add an option for TIFF / FITS / PNG / BMP / JPEG output?
In versions 8.25 and later, "dcraw -T" writes TIFF output
with metadata. To write other formats:
I used the
Netpbm toolkit
in these examples.
ImageMagick
also does command-line format conversions. Both are free.
Why don't you implement dcraw as a library?
I have decided that dcraw shall be a command-line program
written in C, and that any further abstraction layers must be
added around this core, not inside it.
Library code is ugly because it cannot use global variables.
Libraries are more difficult to modify, build, install, and
test than standalone programs, and so are inappropriate for
file formats that change every day.
There's a simpler way to make dcraw modular and thread-safe:
Run it as a separate process. Eric Raymond
explains this technique here.
Why are there false colors along edges within the image?
Because of interpolation. This is a hard problem, easily defined:
Take a three-color RGB image. At each pixel, set two color
values to zero.
Reconstruct the original three-color image as best you can
from the remaining one color per pixel.
Dcraw currently gives a choice of four methods:
Bilinear, Variable Number of Gradients (VNG),
Patterned Pixel Grouping (PPG),
and Adaptive Homogeneity-Directed (AHD).
The Foveon X3 Capture chip requires a different kind of interpolation.
Unlike CCD arrays, it captures three colors at every pixel location.
But the colors are not well separated, so the raw data looks very gray.
Much processing is needed to enhance color while suppressing noise.
Most likely, yes. If your camera is not on the list below,
try dcraw anyway. If it doesn't work, post a raw image to a
website and e-mail me the URL. If you don't have a website, use
Dropload or
YouSendIt.
Ideally, your sample image should show a standard white card
or color chart in direct sunlight, with other colors in the
background.