DNG files – Rawview utility – Generalized Read Raw – Creating Synthetic raw images
The unprocessed digital output of an image sensor is called RAW image data. In this document we sometimes refer to raw files from commercial cameras or development systems as Camera RAW to distinguish them from Bayer RAW files, which are standard monochrome image files that contain undemosaiced (Bayer) data.
|New in Imatest 4.5: RCCC (Red-Clear-Clear-Clear) raw files, used by the automotive industry, are now supported in the Monochrome (Bayer Raw), Generalized Read Raw, and Rawview windows.
New in Imatest 4.2: Direct decoding of Adobe DNG files has been added.
|Bayer Color Filter Array (CFA) The pixels in most digital image sensors are covered with the Bayer CFA, which makes each pixel sensitive to a single primary color, Red, Green, or Blue. The order of the colors is RGRGRG…, GBGBGB…, etc., in alternating rows. There are twice as many greens as reds or blues because the eye is most sensitive to green. The four possible pixel arrangements (Red locations) are shown on the right, where pixel locations start with Row 1 Column 1 (R1C1) at the upper left corner. There is no universal standard for mapping colors (R, G, or B) to pixel position (RmCn). The arrangement can be determined by examining a Bayer RAW image file that contains recognizable colors with the Rawview utility, which can be opened from a button on the right side of the Imatest main window.||
|RCCC (Red-Clear-Clear-Clear) sensors In addition to the well-known Bayer CFA, Imatest 4.5+ supports RCCC sensors, which are used in the automotive industry (where red has special significance). Like Bayer sensors, the red channel can be in any of four positions (two are shown on the right). Rawview can help determine the red position. RCCC images are not demosaiced in the traditional sense; they are converted to monochrome images. The Monochrome settings and Generalized Read Raw windows (shown below) include options to remove the red channel from the total image or select the red channel-only. The methods are described in “Interfacing Red/Clear Sensors…” from Analog Devices.||
|RCCB (Red-Clear-Clear-Blue) sensors can be demosaiced just like Bayer CFA images. They can be analyzed in the same way in the early stages of image processing. Colors won’t resemble regular RGB color images until a strong Color Matrix is applied (to remove the red and blue components from the clear channels).
To be usable in most applications, RAW files must be demosaiced (though many Imatest modules can analyze RAW files directly). Demosaicing (sometimes spelled demosaicking) a form of interpolation that fills in the missing colors for each pixel. It is the primary function of RAW converter programs (which may be either built into the camera or installed on a separate computer). In demosaicing, detail in the missing colors is inferred from detail in other, neighboring colors. Algorithms can be very mathematically sophisticated. A good example (which is the basis of Matlab’s gradient-corrected linear interpolation demosaic routine) in High-Quality Linear Interpolation for Demosaicing of Bayer-Patterned Color Images by Henrique S. Malvar, Li-wei He, and Ross Cutler of Microsoft.
In addition to demosaicing, converting RAW images into standard interchangeable image formats may include
- applying a gamma curve, often with an added tonal response curve (which often has a “shoulder”, i.e., a rounded region),
- white balance and color (matrix) adjustment,
- sharpening, usually in the neighborhood of contrasty features, and
- software noise reduction, typically in the absence of contrasty features.
All these steps can affect Imatest measurements. To minimize their effects (to convert RAW files without sharpening, noise reduction, and tonal response curves) Imatest uses the following techniques:
- For commercial RAW files, which are proprietary to camera manufacturers (e.g., CR2 for Canon and NEF for Nikon) and contain proprietary metadata that may be packed (m pixels into n bits), Imatest uses dcraw, a freely available program for converting commercial RAW images to useful file formats with minimal processing. Dcraw can optionally apply a simple gamma curve (with no additional tonal response curve) and white balancing (based on the camera setting), but it never sharpens or applies noise reduction.
- For the output of manufacturer’s development systems, which is typically pure binary data, 1 or 2 bytes per pixel, Imatest uses Generalized Read Raw, described below. Generalized read raw can optionally apply a simple gamma curve and white balancing (based on the crude “gray world” algorithm). Output images can be color-corrected (using a matrix) in Multicharts or Multitest and sharpened or noise-reduced in Image Processing. An extension has to be specified that corresponds to the file format (most importantly, the number of rows, columns, and bit depth).
Imatest can use RAW files in two ways.
- It can demosaic RAW files, producing standard 3-color RGB image files in TIFF, PPM, PNG, or JPEG format, with TIFF as the default. The advantage of using dcraw or Generalized Read Raw is that they apply no sharpening, no noise reduction, and a straight gamma curve. Dcraw offers several choices for gamma, including 1/2.2 (for typical displays), sRGB (close to gamma = 2.2, but with a linear region in the deep shadows), and 1.0 (true linear). If RAW files are available, cameras and lenses from different manufacturers can be compared on a consistent, fair basis.Dcraw should be used with caution in Colorcheck and Stepchart because is performs autoexposure (automatic white level adjustment) by default. The Auto white level button should be unchecked to get the correct levels. According to the dcraw FAQ, “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.”
- It can convert camera RAW files into Bayer RAW (undemosaiced) files stored in standard monochrome image file formats (TIFF, PNG, or PGM). Most Imatest Master modules can analyze Bayer RAW files.Bayer RAW is valuable for measuring lateral chromatic aberration, which can be strongly distorted by the demosaicing process. It also allows the two raw green channels (Gr and Gb) to analyzed separately. Caution: dcraw may apply some tonal processing, even though the documentation indicates it doesn’t, i.e., gamma measured by Stepchart and other modules may be quite different from the expected value of 1. (This may be due to uncorrected offsets the RAW files themselves).
To use RAW files in Imatest, either
- Click on an Imatest module (SFR, Stepchart, etc.) and open the file just as you would any other image file. If the file extension indicates a camera RAW image file supported by dcraw (CR2, NEF, etc.— even Phase One RAW TIF files), the dialog box shown below for setting dcraw parameters is opened. If the file extension has been entered into Generalized Read Raw, the file will be read and decoded according to the Read Raw settings.
- Click on the dcraw box on the right side of the Imatest main window (or click Modules, Run dcraw) to run dcraw as a standalone application: the output file will be saved but no Imatest module will run. The dialog box shown in the dcraw section below is a graphic user interface (GUI) front-end to dcraw that allows you to select several of dcraw’s options.
Processing files with dcraw
The best way to be sure an image file used by Imatest faithfully resembles the RAW file— that it has a straight gamma curve, no sharpening, and no noise reduction— is to read a RAW file into Imatest and convert it to a standard format (TIFF, PPM, etc.) using Dave Coffin’s dcraw. If you select any of the standard RAW formats (CRW, NEF, etc.) or if raw data is detected (e.g., Phase One TIF files) the dialog box shown above appears. It is a front-end to dcraw that allows you to choose between several RAW conversion options.
dcraw settings window
Dcraw can either (A) demosaic camera RAW files with minimal processing— no sharpening, no noise reduction, and a simple gamma curve, or (B) convert them to standard 8 or 16-bit monochrome file formats (TIFF or PGM) that contain Bayer RAW (undemosaiced) data, which can be analyzed by several Imatest Master modules. This conversion has the following choices:
|Demosaicing||Normal RAW conversion (demosaiced)|
|RAW 8-bit (Bayer RAW; no demosaicing)|
|RAW 16-bit (Bayer RAW; no demosaicing)|
If the second or third option above (RAW 8-bit or RAW 16-bit) is selected, most the Demosaicing area (above) is grayed out and the output of dcraw is a monochrome TIFF or PGM file that contains undemosaiced (Bayer RAW) data from the image sensor.
Note: the pixel levels and gammas of undemosaiced (Bayer RAW) files do not appear to be reliable as of July 2009. Levels are too dark if Auto white level is unchecked, and the gamma is incorrect (for Canon RAW files). Exposure and gamma are reliable with normal RAW conversion (with demosaicing).
Several dcraw programs are available. This list may not be up-to-date. Open the dcraw window to see the current selections.
|Program||dcraw||The original; may not work in Vista or later versions of Windows
|dcrawMS||Works in Vista|
DCrawMS.exe is a special build of dcraw designed to work with Vista and Windows 7. If you have a recent camera that doesn’t work with dcraw or dcrawMS, try downloading the latest versions from Pukkita’s Digital Darkroom Corner to the Imatest installation folder (C:Program filesImatest in most English language installations).
If Normal RAW conversion (demosaiced) has been selected, the Demosaicing box contains several options, most of which are explained in more detail in the dcraw Manpage. The following output color spaces are available for demosaiced output.
|RAW (not true RAW pixels).
Demosaiced with no color space conversion or White Balance.
The camera’s color profile is needed to correctly interpret the colors. Gamma = 0.45.
|sRGB, Adobe RGB (1998), Wide Gamut RGB, ProPhoto RGB, and XYZ.|
Profile tags are embedded in the output file for the four standard color spaces. Several demosaicing quality levels (using different algorithms) are available (and worth exploring). See the dcraw Manpage for details. Auto white level is the default. It should be turned off for tonal measurements.
Dcraw converts RAW files into TIFF files, with the obscure PPM format available as an option. If check the box to delete the converted (TIFF) file, you may save the image in one of two compressed formats: PNG (lossless compression; takes longer) or JPEG (lossy compression; maximum quality; 24-bit only).
A list of supported cameras appears on the dcraw site. New cameras are typically added within one to three months of their introduction. The dcraw version included with Imatest sometimes falls behind. Francisco Montilla provides Mac OS and Windows executables on his website.
When a monochrome file is opened by an Imatest Master module that supports Bayer RAW analysis, the dialog box shown below appears. (It won’t appear if Do not display this window… has been checked. It can be restored by clicking Settings, Monochrome read dialog… in the Imatest main window.)
The four buttons on the left cause immediate action (the window closes and processing continues):, , and . , and .
should be selected for ordinary monochrome image files that do not contain Bayer RAW or RCCC data.
For Bayer RAW and RCCC files the color interpretation depends on the Pixel color mapping selection (Red in R1C1 for Canon; Red in R1C2 for Panasonic, etc.) The correct setting for Bayer raw images can be found by running the Rawview utility on an image with recognizable colors. Bit shift may be useful for 16-bit images that are often dark without a shift.
processes the image, which consists of four channels (Red, Green (Red row), Blue, and Green (Blue row)— abbreviated R, G(r), B, G(b)) without demosaicing. The primary channel to display (and in some cases analyze) is selected in the Primary channel to analyze dropdown menu. This setting may be overridden in individual modules (it’s not critical).
either demosaics the image (appropriate for Bayer sensors) or processes it as RCCC. The demosaicing or RCCC processing algorithm must be selected in the dropdown menu to the right of the button. Options are shown below.
The Demosaic dropdown menu has the following options.
|Matlab (Gradient-corr. linear interpolation) recommended||For Bayer sensors. The output is a color image. Uses Matlab’s moderately high quality demosaicing algorithm, derived from High-Quality Linear Interpolation for Demosaicing of Bayer-Patterned Color Images by Malvar, He, and Cutler.
|Bilinear (simple, low quality,
less sharp; not recommended)
|For Bayer sensors. The output is a color image. This choice is generally not recommended.|
|RCCC sensor: Red channel removal (simple; full resolution)||Output is a full-resolution monochrome image for the clear pixels. Red channel is removed by interpolation using the 4-pixel averaging kernel in Fig. 4 of the Analog Devices white paper.|
|RCCC sensor: Red channel-only
(simple; half (linear) res)
|Output is a monochrome image for the red channel-only, with half the linear resolution of the input image.|
|RCCC sensor: Red row removal
(changes aspect ratio)
|Output is a monochrome image for the clear pixels with half the original number of rows.|
|RCCC sensor: Red column removal
(changes aspect ratio)
|Output is a monochrome image for the clear pixels with half the original number of columns.|
The RCCC sensor options use processing described in “Interfacing Red/Clear Sensors…” from Analog Devices. The output is a monochrome image. (Additional options may be added.)
White balance is available for the two demosaicing options. It does not apply to RCCC.
Recognizing Bayer RAW patterns
Bayer RAW images are typically monochrome files (though they can be color if they are acquired using screen capture— Alt-PrtSc). They sometimes appear unexpectedly in development/prototyping systems. You can avoid serious headaches if you recognize them. They are characterized by square patterns similar to those shown on the right.
Bayer RAW characteristic patterns
If a Bayer RAW color has been selected, one of four image planes is selected, depending on Pixel color mapping and the button pressed (, , etc.). (There is no universal standard mapping an image plane with a color.) Four planes that could be analyzed for the button are shown below. Note that the height and width in pixels of the image in each plane is half that of the image as a whole and the spacing between pixels is twice that of the sensor pixel spacing.
(There is no universal standard for mapping colors to image plane.)
|This is the recommended method for reading raw files for image sensor noise
or veiling glare (flare) measurements. Because dcraw does not always handle
pixel offsets (pedestals) correctly, we recommend converting raw files to DNG format,
then directly reading them into Imatest.
Starting with version 4.2, Imatest can directly read DNG (Adobe Digital Negative) files. Previously, DNG files could only be read using dcraw.
Although DNG format offers little advantage when files are demosaiced, it has a significant advantage for measuring
- image sensor dynamic range, which requires linear undemosaiced (Bayer) raw file data with pixel levels ranging from 0 for pure black to the maximum for the bit format (typically 65535 for 16-bit depth), and
- veiling glare, where any pixel level offset (pedestal) can throw off the measurement.
The problem is that different cameras have different black level offsets (minimum pixel values) and white (saturation) levels, and these values are hard to determine because manufacturers record them with different EXIF tags (if at all). These values are usually applied to dcraw processing when images are demosaiced, but are usually ignored when images are not demosaiced (and not saved in the EXIF data), i.e., dcraw is not robust when offsets are present. They need to be applied to obtain a valid sensor dynamic range calculation. This is done automatically for raw files that have been converted to DNG, which is a special type of TIFF file that uses standard tags for linearization and for black and white level correction. See Processing RAW Images in MATLAB for an overview.
Any commercial raw file (CR2, RW2, NEF, etc.) can be converted to DNG format using the Adobe’s free DNG Converter To download it, go to Adobe’s download page for Windows or Macintosh, and follow the instructions. Adobe Digital Negative Converter runs in a GUI window. To use it for undemosaiced files, open it and click Change preferences to open the Preference window, then select Custom… in the Compatibility dropdown window to open the Custom DNG Compatibility window. Linear (demosaiced) should be unchecked and Uncompressed should be checked, as shown on the right.
Operation of the DNG converter is simple and straightforward. Note that all files in a folder will be converted, so if you want only a limited number of files to be converted, you’ll need to move them to a separate folder.
To take advantage of this capability, the setting shown on the right, 3. Read DNG files directly then linearize and correct for black level offset, must be selected in the Options II window, which can be opened from a button on the lower-right of the Imatest main window or in the Settings dropdown menu of the Imatest main or Multicharts window. When this setting is selected, DNG files read into Imatest have pixel level = 0 for pure black and have a maximum pixel level of 2bit depth-1: (65535 for bit depth = 16), making them well-suited for measuring sensor dynamic range.
The Rawview utility allows you to determine the color arrangement of Bayer RAW files (Red in R1C1, R1C2, R2C1, or R2C2) by trying each and selecting the one that looks best. The image can be saved as an RGB file if needed. It can be opened by pressing the button on the far right of the Imatest main window. When Rawview is first opened, instructions similar to those shown below appear. (They are likely to be more up-to-date.)
|Welcome to Rawview. Preview Bayer RAW files.You can find the relationship between colors and pixel locations.
The input file should be a monochrome file (r x n x 1 pixels) that contains Bayer Raw or RCCC data.
The image is not fully demosaiced: it has only half-resolution.There is no White Balance. Colors may appear weak.
16/48 bit images are lightened to improve visibility.
The input image should have some strong, identifiable colors.Start by pressing “Read (Bayer) RAW image file.”
Click on “Red in RmCn…” popup menu and determine which selection looks correct.
For RCCC files, click on each RmCn-only setting. The Red channel will be darker.
After the image file has been read, the Rawview window looks like this:
The Rawview window (no zoom)
The zoom function is always active: the image can be zoomed in to better view key details. The Imatest modules, affecting some displays.button is enabled whenever the Red in RmCn selection is changed. It sets the default for opening Bayer RAW files in
Note that Rawview performs no White Balance, so the balance you see represents the color balance in the sensor, which may be of interest. It is rarely neutral.
|Imatest 4.5+ supports RCCC (Red-Clear-Clear-Clear) sensors, which are widely used in the automotive industry. To determine which position (RmCn) contains the Red channel, click on each of the RmCn-only settings (example: R1C1-only (for RCCC)) in the dropdown menu on the lower-left (Red in R1C2 is displayed above). The position with the Red channel will look different— darker than the others. This position can be used in the Monochrome (Bayer Raw) and the Generalized Read Raw settings windows.|
Two options are available for saving images as an RGB files:saves the image as a low resolution RGB file using the R, (one of the) G, and B channels without demosaicing. The vertical and horizontal resolution is half that of the original file (total pixel count is 1/4 of the original). uses Matlab’s standard gradient-corrected linear interpolation demosaicing algorithm to save the image in a full resolution RGB file.
Rawview dropdown menus include display options and Save commands.
- Read Bayer RAW file Read the Bayer RAW file (must be in a standard image file format: TIFF, etc.)
- Save Screen Save the contents of the screen. Optionally display it if the Display screen checkbox is checked. You need to set the viewer before the first time you display the screen this way. Irfanview is an excellent free viewer.
- Save image as RGB file Save the image as an RGB file, which has half the pixel dimensions (resolution) on the original file. This does not involve a demosaicing algorithm. The contents of the R, selected G (G(R) or G(B)), and B channels are identical to the undemosaiced channels.
- Adjust 16-bit images Brighten 16-bit images (which are linear or nearly so, i.e. gamma near 1.0) if needed to enhance display.
- Brighter 16-bit images Brighten 16-bit images further for additional display enhancement.
- Online Help opens this page in your default web browser.
Generalized Read Raw
Binary RAW files created in engineering development systems not supported by dcraw, but in most cases you can read them (even though they’re not standard image files) using Imatest’s Read RAW capability. This capability allows you to demosaic these files or to measure MTF of undemosaiced (Bayer raw) files (interpreted as standard monochrome files) when White Balance (WB) is applied.
Generalized Read Raw is mostly for binary files taken directly from manufacturer’s development systems. For the proprietary RAW formats in commercial cameras, where data is packed, for example where four 12-bit pixels are squeezed into 3 bytes, dcraw should be used.
To read generalized RAW files you must specify a file extension (up to 16 can be registered) and associate read parameters with that extension. This can be done in the following steps.
Click the button in the Utility tab on the right of the Imatest main window or Utility, Read Raw. The following dialog box opens. Entries should be based on manufacturer’s data sheets where possible, but some trial-and-error is usually required. If you know the image width and height (in pixels) setup is usually very fast. If you make an incorrect choice, two plots will be displayed (below) to help determine the correct width and height values.
- File extension. Select the extension index (1-16) with the dropdown menu on the upper-left. (This number selects which of the 16 extensions to edit.) Enter the extension (3 or more alphanumeric characters) in the box on the right. If possible, it should be one of the extensions not recognized by dcraw. The settings for this extension will be saved when you click OK or Convert/Test (which tests them by reading and displaying a file).
As of October 2009, the following extensions (listed in www.cybercom.net/~dcoffin/dcraw/rawphoto.c) are recognized by dcraw: 3fr, arw, bay, bmq, cine, cr2, crw, cs1, dc2, dcr, dng, erf, fff, hdr, ia, jpg, k25, kc2, kdc, mdc, mef, mos, mrw, nef, nrw, orf, pef, pxn, qtk, raf, raw, rdc, rw2, sr2, srf, sti, tif, and x3f.
- Input pixel size How pixels are stored in the file. Choices are uint8, uint16, and uint32 (unsigned 8, 16, and 32-bit formats). In the future other formats may be added (more complex to implement), for example, for 2 12-bit pixels stored in 3 bytes.
- Output pixel size How pixels are stored in Imatest. Choices are uint8, uint16, or uint32 (for HDR files).
- Bit shift The amount to shift bits: Auto or 0, ±2, ±4, ±6, or ±8. Usually needed to get correct levels for analysis. Negative numbers lighten the image. Auto is usually recommended unless absolute levels are required.
|Warning: be cautious in applying bit shift, and especially Auto bit shift, to measurements that require absolute levels, particularly with 16-bit output files where the original sensor has 10-14 bits of data (resulting in padded files). Such measurements include hot/dead pixels (in Uniformity and Blemish Detect), Color Correction Matrix (in Multicharts), etc.|
- Pixel offset An integer number to subtract from the pixel levels. Used when there is a pixel level “pedestal”. Test carefully, especially if Bit shift is applied (it is applied before Bit shift).
- Byte ordering IEEE Little or Big-Endian. Affects results when Input pixel size is uint16. See wikipedia.org/wiki/Endian.
- Width Image width in pixels. Can usually be obtained from manufacturer’s data sheets. If you enter an incorrect number for width and height (if Width x Height &un, two additional plots are displayed (see below) that help estimate the width.
- Height Image height in pixels.
- Transpose Switches rows and columns. Usually checked.
- Rotate/Mirror Allows the image to be rotated by multiples of 90 degrees and/or mirrored.
- Pixels to skip The number of pixels to skip at the start and end of the file.
- White balance None or Simple White Balance (gray world; darken or lighten). Simple WB sets the gain on the four channels so their mean is identical (the lowest of the four means if “darken” is selected; the lightest if “lighten” is selected). It’s not a sophisticated algorithm— it only works for mostly gray test charts (some color is tolerated as long as the average is close to neutral gray). WB allows you to interpret the image as a standard monochrome file (rather than a Bayer RAW channel with only 1/4 the pixels) that can be analyzed for MTF with any of the sharpness modules (SFR, SFRplus, Log F-Contrast, Star Chart). A slanted edge without and with WB is shown below. In this case, white balance was not far off to begin with. For full color correction, we recommend calculating a Color Correction Matrix (CCM) using the decoded image.
|SFR edges: without and with White Balance|
- White level No change or Auto: 99% of saturation. The Auto: 99% setting sets the highest pixel to 99% of the saturation level (252 for 8-bit files; 64880 for 16-bit files). This usually lightens the images, especially if Bit shift is not set to the optimum value.
- Unpack Settings for unpacking specialized packed files (MIPI, Android). Updated on user request.
- Gamma Apply gamma encoding to the image. Gamma = 1 is standard. 0.4545 (or 0.5) is close to standard color spaces.
- Help Opens this web page.
- Demosaicing Choose between none (monochrome output), a demosaicing routine (for Bayer images; color output), or RCCC processing (monochrome output). Selections are similar to the Monochrome window (above; repeated here).
|None (Bayer raw output)||Monochrome output: same as input.|
|Matlab (Gradient-corrected linear interpolation)||Color output: High quality demosaicing, Uses the Matlab demosaic function. Recommended for Bayer raw files.
|Bilinear (simple, low quality; not as sharp)||Color output: Low quality; poor sharpness. (Was a special customer request.) Not recommended.
|RCCC sensor: Red channel removal
(simple; full resolution)
|Monochrome output with red channel removed by interpolation. See “Interfacing Red/Clear Sensors…” from Analog Devices. It is OK to select “None”, and perform the RCCC processing later in the Monochrome/Bayer Raw window. If the red channel location is not known, select “None”, and use Rawview to find the location.|
|RCCC sensor: Red channel-only (simple; half (linear) res)||Monochrome output: red channel-only.Output has half the linear resolution (1/4 the pixels) of the input.
|RCCC sensor: Red row removal
(changes aspect ratio)
|Output is a monochrome image for the clear pixels with half the original number of rows.|
|RCCC sensor: Red column removal
(changes aspect ratio)
|Output is a monochrome image for the clear pixels with half the original number of columns.|
- Bayer arrangement (location of red channel).
- Output file Save the file. None (do not save; read-only), PNG, JPEG, TIFF or HDR (Radiance) file. Undemosaiced files can be opened with Rawview.
- Convert/Test Saves the settings, then reads and displays a raw image file or batch of files (example on right). If the actual size of the file read is not equal to the Pixel Width x Height, the image will be displayed with the same Width and an adjusted height and two diagnostic images (shown below; for estimating the correct width) are displayed. The text below the plot displays the specified Width, Height, and W x H and the actual number of pixels returned (which will equal W x H if the correct values have been chosen). Available output formats include PNG, JPEG, TIFF, and HDR (Imatest 5.0+).
- OK Saves the settings and closes the Read Raw setup window.
- Cancel Closes the window. Does not save the settings.
Estimating image width and height
If the number of pixels read, excluding the skipped pixels at the beginning or end of the file, is not equal to the specified (Width x Height), two diagnostic plots are produced and the periodicity (normally equal to the pixel width) is estimated. The image on the right is what we get if we enter a deliberately incorrect value for Width (2590 instead of 2592). It’s only a little off. Most of the time the resulting image is unintelligible.
The first added plot shows the levels of 215 = 32768 pixels near the middle of the file. It gives a good idea of the periodicity, but it’s very difficult to read the exact number from this plot.
The second added plot estimates the periodicity (the most likely image width in pixels). It is derived by taking the fourier transform of the data in the first plot, calculating the absolute value (i.e., removing the phase), then taking the inverse fourier transform. The location of the first major peak (above 0) is the most likely periodicity. In this case it’s 2592, shown on the upper right. This estimate may not work for all images. If necessary, you can zoom in by drawing rectangles around the region of interest. You may need to zoom in more than once to find the precise location of a feature. Double-click to zoom out.
(This is the “make-a-fake” operation, added in Imatest 5.1) There are occasions where raw images are needed to analyze the performance of signal processing algorithms, but real raw images (from cameras) may not be available. For such situations, images used in Rescharts, Multicharts, Uniformity-Interactive, and Image Processing can be saved as pseudo-raw images.
Where high quality images are needed, we recommend running the Test Charts module and saving the chart image. Test Charts produces two types of image file: bitmap charts, which can be loaded directly into any of the modules listed above, and SVG (Scalable Vector Graphics) files, which can be opened and edited in Inkscape (an outstanding free open-source program) and exported as bitmap (PNG) files. Both types of image can be edited, for example to change a black & white image to black and red or blue (worse cases for Bayer demosaicing). We frequently recommend the Image Processing module, which can read any file image and degrade the image (adding noise, blur, etc.) then enhance the image (using tone mapping, bilateral filter, Unsharp Mask, etc.).
To save a “pseudo-raw” file, click on the File dropdown menu on any of these modules, then click on Save pseudo-raw/remosaiced image. This opens the Save (re)mosaiced image dialog box.
This window offers numerous processing and save options.
- Mosaicing or channel selection determines the basic operation. Choices are
None (Normal color file output)
Remosaic (Bayer format) (default— standard Bayer mosaicing.)
RCCC (Red-Clear-Clear-Clear): R bright
RCCC (Red-Clear-Clear-Clear): R = C/3
Monochrome (Y = luminance)
Monochrome (mean: equal weights)
- Red channel location This applies to Bayer-mosaiced and RCCC images.
1. Red in R1C1 (RGGB)
2. Red in R1C2 (GRBG)
3. Red in R2C1 (GBRG)
4. Red in R2C2 (BGGR)
1. Keep orientation (default)
2-4. Rotate CCW 90, 180, 270 degs
5. Mirror (no rotate)
6-8. Mirror, Rotate CCW 90, 180, 270
- Gamma adjust (multiplier) (defaults to 1) This is used to more-or-less restore linear tonal response to pseudo-raw images derived from gamma-encoded images. For a typical color space file, with encoding gamma near 0.5, gamma = 2 is appropriate. Even better: use the inverse of encoding gamma measured from a grayscale chart.
- Save file format selects format for saving the file. Four standard image file formats can be selected: PNG (default), JPG, TIF, and BMP. PNG is frequently a good choice because it’s losslessly-compressed, and smaller than TIF or BMP files. JPG produces compact file sizes (but JPEG is not generally recommended because lossy JPEG compression can affect isolation between channels). Standard image files can be examined with Rawview.
Two binary formats can be selected: 8 and 16-bit. These can be decoded with Generalized Read Raw.
- Extension (for binary) is only enabled when one of the binary formats (above) is selected. Select a name for the extension (often RAW, but a unique extension is recommended).
- Green channel emphasis makes the saved file look more like typical raw files, where the green channel tends to have more energy than the other channels. Selections are
No emphasis: RGB equal weighting (default)
Green (Blue/2, Red/2)
Green (Blue/3, Red/3)
Green (Blue/2, Red/4)
Green (Blue/4, Red/2)
Preview opens a preview image, typically displayed as a mosaiced (Bayer-raw) monochrome image. Save the image and use Rawview to see what the demosaiced image will look like.
Processing RAW Images in MATLAB by Rob Sumner (Department of Electrical Engineering, UC Santa Cruz) A nice introduction to RAW files and how they are processed.