IJ Plugins: ij-dcraw

Reader for Digital Camera Raw Images

The Reader plugin opens digital camera raw images using DCRAW program created by David Coffin. Raw rormats for over 500 cameras are supported. Full list can be found at dcraw home page.

You can control how raw or how processed the opened image is. This enables extracting sensor data that is lost when image is converted to standard viewing format. You can chose to concentrate, for instance, on image analysis rather than on making an eye-pleasing picture.

The Reader requires the dcraw binary specific to an operating system. Versions for Linux and Windows are part of the distribution. Version for Mac OS X is available through dcraw home page.

Plugins

  • DCRaw Reader - Opens over 200 formats digital camera raw images. It is a wrapper for dcraw executable. In a background a raw image is converted to PNM image and the read into ImageJ. Located under Plugins/Image IO.

    JAI Reader with Preview plugin
  • About DCRaw Reader - Shows brief info about the RCRaw Reader plugin. Located under ImageJ menu Help/About Plugins.

Tips & Tricks

If you wander what is going on behind the scenes, how dcraw executable is used, you can see the exact command line the ij-dcraw is executing by turning on Debug mode. Select in ImageJ menu: Edit > Options > Misc and select Debug Mode. Now open an image using DCRaw Reader and watch the Log window, it will show the command line with the options used and the output log generated by dcraw.

Sample ImageJ macro for batch image conversion

    //Get File Directory and file names
    dirSrc = getDirectory("Select Input Directory");
    dirDest = getDirectory("Select Output Directory");
    fileList = getFileList(dirSrc);
    caption = "dcraw batch converter";

    print(caption + " - Starting");
    print("Reading from : " + dirSrc);
    print("Writing to   : " + dirDest);

    // Create output directory
    File.makeDirectory(dirDest);

    setBatchMode(true);
    fileNumber = 0;
    while (fileNumber < fileList.length) {
        id = fileList[fileNumber++];

        print(toString(fileNumber) + "/" + toString(fileList.length) + ": " + id);

        // Read input image
        run("DCRaw Reader...",
            "open=" + dirSrc + id + " " +
                "use_temporary_directory " +
                "white_balance=[Camera white balance] " +
    //            "do_not_automatically_brighten " +
                "output_colorspace=[raw] " +
    //            "document_mode " +
    //            "document_mode_without_scaling " +
                "read_as=[8-bit] " +
                "interpolation=[High-speed, low-quality bilinear] " +
    //            "half_size " +
    //            "do_not_rotate " +
    //            "show_metadata" +
                "");
        idSrc = getImageID();

        // Save result
        saveAs("Tiff", dirDest + id);

        // Cleanup
        if (isOpen(idSrc)) {
            selectImage(idSrc);
            close();
        }
    }
    print(caption + " - Completed");

Using ij-dcraw directly from Java

// Input file
final File inFile = new File("test/data/IMG_5604.CR2");

// dcraw wrapper
final DCRawReader dcRawReader = new DCRawReader();

// Listen to output messages
dcRawReader.addLogListener(new DCRawReader.LogListener() {
    @Override
    public void log(String message) {
        System.out.println("message = " + message);
    }
});

// Execute dcraw
dcRawReader.executeCommand(new String[]{
        "-v", // Print verbose messages
        "-w", // Use camera white balance, if possible
        "-T", // Write TIFF instead of PPM
        "-j", // Don't stretch or rotate raw pixels
        "-W", // Don't automatically brighten the image
        inFile.getAbsolutePath()});

// Cleanup
dcRawReader.removeAllLogListeners();

// Load converted file, it is the same location as original raw file but with extension '.tiff'
final ImagePlus imp = IJ.openImage("test/data/IMG_5604.tiff");

Download

Latest version ij-DCRaw plugin, including binaries for Windows and Linux, can be downloaded here.

Installation

Plugins are distributed in file ij-dcraw_.jar available in ij-dcraw package at: http://ij-plugins.sourceforge.net/.

Plugins are installed by simply coping the ij-dcraw_.jar to ImageJ plugins directory. The plugins are available under Plugins/Image IO menu, brief help for each plugin is available under Help/About Plugins menu.

By default, the Reader looks for the dcraw binary in subdirectory dcraw of ImageJ plugins folder. An alternative location can be specified by adding property ".dcrawExecutable.path"' to ImageJ properties file IJ_Props.txt located in ImageJ home directory. Here is an example:

Example: IJ_Props.txt

    .dcrawExecutable.path=/apps/dcraw/dcraw.exe
    

Note period at the beginning of property name, it is required by ImageJ.

Requirements

  • Reading of 48 bit RGB images requires ImageJ v.1.35p or newer. Earlier versions of ImageJ will support only regular 24 bit RGB images.

  • Java 6 or better.

  • dcraw executable (see Installation section for more details).

Links