Documentation – Current v24.2

Image file formats and acquisition devices

Current Documentation

All documentation versions


Imatest
can read a great many file types, including many not supported by standard Matlab. Imatest can also acquire files from a large number of devices. This page lists the file and device types. It is divided into four sections:

Standard (interchangeable) image filesHDREXRSpecial TIFF formatsYUVTGADPXCSVHEIC 
Video files – Raw files: Commercial  – Generalized Read Raw – DNG Acquisition devices

 

Defective image files

Incorrect file extension

Most file types are recognized by their extensions, which are case-insensitive. Sometimes a file has an incorrect extension (for example, a PNG file might have a JPG extension). Imatest has trouble reading these files. If you have trouble reading a file, we recommend opening it in Irfanview (a great free utility; strongly recommended). It will give you a message explaining the issue and suggesting an action (typically renaming the file with the correct extension).

“Laundering” defective files  Sometimes a file can’t be read by Imatest (which depends on Matlab libraries), but can be read by Irfanview, which evidently has more robust read routines. In such cases you can use Irfanview to “launder” the image file by saving it (typically with a slightly different name to indicate that it’s not the original file). This usually works well, but the case below is a rare exception.

color_or_not.png

Color or not?

Image files are either color or monochrome, but we recently found a file that was color, but appeared to be Monochrome in the Windows Properties display and when opened by Imatest. You can download this image (on the right) by clicking or right-clicking on it. This image displays correctly in Windows Explorer (with Icon view), but when you right-click on the image, select Properties, then click on the Details tab, it shows Bit depth = 8, which indicates a monochrome image (it would be 24 or 48 for color). Imatest, which uses Matlab libraries, opens it as a monochrome image. If you open the file in Irfanview, then save it as a PNG or TIFF, it still opens as a monochrome image, but if you save it as a JPEG, it opens as a color image. 

We don’t have a general recommendation about what to do in such cases, other than be aware that files can get corrupted in strange ways, and should be carefully examined if a program behaves strangely. If possible, try to fix the problem at the source, which typically involves getting the (EXIF) metadata correct.

Standard (interchangeable) still image files

All the still image file types supported by the Matlab imread function.

BMP — Windows Bitmap JPEG (JPG) — Joint Photographic Experts Group PNG — Portable Network Graphics
CUR — Cursor File JPEG 2000 (JP2, JPX) PPM — Portable Pixmap
GIF — Graphics Interchange Format PBM — Portable Bitmap RAS — Sun Raster
HDF4 — Hierarchical Data Format PCX — Windows Paintbrush TIFF (TIF) — Tagged Image File Format
ICO — Icon File PGM — Portable Graymap XWD — X Window Dump

Common file formats are shown in boldface. For full details, see Matlab documentation:  imread. Special cases of standard files are described below.

HDR (High Dynamic Range) files

Files with the HDR extension are read with the Matlab hdrread function and can be written by Read Raw, Image Processing and other Imatest modules using Matlab hdrwrite. These files have the Radiance HDR format.

EXR (OpenEXR)

Files with EXR extension are read using the OpenEXR library. OpenEXR is commonly used to store high dynamic range images encoded in the Academy Color Encoding System (ACES),  providing support for 16-bit floating-point, 32-bit floating-point, and 32-bit integer pixels.  Files with both “R”, “G”, “B” and “Y”, “BY”, “RY” channels are supported. The latter is internally converted to linear RGB colorspace with Rec.709 primaries. Any other channels are currently ignored. Maximum pixel value is limited by 1.0 and currently is clipped at this level. Values of “R”, “G” and “B” channels are read as they are stored in the file (no additional colorspace conversions are made). 

PGM (Portable Graymap) files

Files with the PGM extension are read with the Matlab imread function and can written by Image Processing. Some PGM files may require the Endian order to be swapped in order to be read in correctly. This can be done by checking the “PGM file read: swap Endian order” box in the Options II settings window before read in. The Options II window can be accessed from the Settings menu in the main Imatest window. 

Multi-image tiff

Some tiff tiles (extension tif or tiff) contain multiple images. These could be for a multispectral camera for different wavelength bands, or they may have different sizes. When these files are detected, Imatest lets you select which image to analyze.

By default, the Multi-image TIFF file selection window opens whenever a multi-image TIFF file is read.

multi_image_tifMulti-image TIFF file selection window

If you don’t want this window to appear during file reads, uncheck the Display this window… checkbox. (The image number to read is saved.) You can always open it from the Settings dropdown menu of the Imatest main window.

When opened during a file read, the image preview appears only after the Preview image checkbox is set.

When opened from the Settings dropdown menu, no image appears until you press Read file to view.

Currently, Imatest can’t analyze images from multi-image files in batches. (Images in multi-image files don’t always have the same size.) To prepare images for batch analysis, you can save the selected single image or all images (with _01 through _nn appended to the file name) by clicking one of the buttons on the upper-right.

Phase One raw tiff

Phase One raw files have the tiff extension. They are large files (>10MB), but the first image is a small thumbnail (width < 400 pixels; height < 300 pixels), and they are labeled as Phase One. When these files are detected they are treated as raw files, to be converted by LibRaw.

YUV 

Four types of YUV420 and one type of YUV422 can be read in Imatest 2020.2. YUV files are converted into RGB format in Rec.709 color space (similar to sRGB).

YUV settings in Options II

YUV files are recognized by the yuv file extension.

Because YUV files are pure binary files with no metadata, they contain no information on format and image size. YUV format and and image Width and Height (which default to 1080P settings) should be set in the Options II window at the lower-right of the Imatest main window. Settings are shown on the right.

YUV format (which specifies the arrangement of Y, U, V color data) can be determined by trial-and-error using an image with recognizable color (Colorchecker charts work really well). Only one setting will have correct colors.

Supported YUV formats
Dropdown menu  Description 
YUV 420 (U then V) P  → RGB Y′UV420p (and Y′V12 or YV12) to RGB888 conversion
YUV 420 (U,V interleaved) SP NV12 → RGB Y’UV420sp (NV12) to RGB conversion
YUV 420 (V,U interleaved) SP NV21 → RGB Y′UV420sp (NV21) to RGB conversion (Android)
YUV 420 (V then U) P → RGB  
YUV 422 (Y,U,Y,V interleaved) → RGB Interleaved columns of Y,U,Y,V 
YUV 422 (UYVY) → RGB
U0 Y0 V0 Y1   U1 Y2 V1 Y3    U2 Y4 V2 Y5
Interleaved columns of U,Y,V,Y
Microsoft Ignite Recommended 8-bit YUV formats
YUV 422 (YUY2) → RGB
Y0 U0 Y1 V0   Y2 U1 V3 V1   Y4 U2 Y5 V2
Interleaved columns of Y,U,Y,V
Microsoft Ignite Recommended 8-bit YUV formats

 

The diagram on the right shows the order of Y, U, and V data for the standard (P = Planar = non-interleaved) YUV420 configuration. About YUV Formats (on Github) shows no less than four YUV420 formats.

We can add additional YUV formats (there are many) on customer request. We will need an image with recognizable color so we can test the code.

 

Targa (TGA extension)

According to Wikipedia, Truevision TGA, often referred to as TARGA, is a raster graphics file format created in 1984 by Truevision Inc. (now part of Avid Technology).

DPX

Digital Picture Exchange (DPX) is a common file format used by the cinema industry for digital intermediate and visual effects work and is an ANSI/SMPTE standard (268M-2003). DPX supports several bit depths, but Imatest hasn’t been tested for all possible variations. If you run into difficulties, please contact us at support at imatest dot com.

A curiosity of the the DPX format is that the R and B channels may sometimes be switched (it’s not consistent in sample images we’ve downloaded from the web), and the order is not specified in the DPX header field. To handle this, the Settings dropdown menu of the Imatest main window has a DPX read: reverse RGB setting, which may or may not be checked. You should select the setting that gives correct colors.

CSV

Yes, old-fashioned Excel-readable CSV files have been used for storing infrared images. (This is, of course, hideously inefficient, and may well be obsolete.)

HEIC 

High Efficiency Image Container: an image file format developed by Apple for iPads and iPhones, and NOT YET SUPPORTED by MATLAB or Imatest. We will add support as soon as we find a suitable MATLAB program or Mathworks adds it to imread. In the meantime, this MATLAB Answers page— How to import “.heic” image file of Apple phone by matlab? — recommends the ImageMagick mogrify function

Raw files

Raw files contain linear data taken (more or less) directly from the image sensor output. They are typically not demosaiced, gamma-encoded, color-corrected, white-balanced, sharpened, or noise-reduced. To be usable in most applications, they must be converted to interchangeable formats. Imatest’s raw file support is described in detail in Raw files.

Commercial raw files

LibRaw settings window

Commercial raw files (Canon, Nikon, Panasonic, Sony, etc.) have proprietary formats that are complex to decode. In Imatest they are converted to standard interchangeable still image formats by LibRaw, which is included with Imatest (it has replaced dcraw, which is no longer kept up-to-date).

You can, of course, convert them externally with any number of raw converters. Some customers use universal raw converters, such as Adobe Lightroom or RawTherapee, to get consistent signal processing with a wide range of cameras.

Although a list of supported cameras is available, there is no list of supported file extensions. Here is an older list, which may omit some current extensions.

3fr,arw,bay,bmq,cine,cr2,cr3,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,x3f

Files with these extensions (except for raw, which is widely used for development system raw files) are decoded by LibRaw. Notable raw formats in the list are ARRIRAW format (ARW; for still frames from Arri cinema cameras), Adobe Digital Negative (DNG; Adobe’s attempt to standardize commercial raw formats– hasn’t gotten a lot of industry traction), and Fuji X-Trans sensors (which deviate from the standard Bayer pattern).

Imatest has a GUI front-end for LibRaw, shown on the right, that lets you select many options (demosaiced or Bayer raw, bit depth, linear or gamma-encoded, white balanced or not, converted to a color space or not). Details in Raw files – LibRaw demosaicing.

Generalized read raw (binary/development system raw files)

Generalized Read Raw setup window

Binary files, typically from development systems, are decoded using Generalized read raw (details here), which is particularly useful for Imatest IT (the Industrial Testing edition), used for manufacturing quality control.

Generalized read raw files are identified by their extension, which is set by the user in the File extension settings section of the setup window. Up to 16 extensions can be registered. (When we receive these files from customers, they almost always have the .raw extension, so we have to give them unique extensions.)

A great many options are available: the most important are width, height, and input and output pixel size (bit depth). Others include bit shift (auto, fixed, or none), pixel offset (defaults to 0), byte order (for 16+ bit depth: Little or Big Endian), rotation/mirroring, white balance and level, and demosaicing. Details in Raw files – Generalized Read Raw

Adobe DNG

Adobe DNG files are a special type of raw file, intended to be a standard used in multiple cameras. They are particularly valuable for measuring image sensor dynamic range.

We mention them here because Imatest has several methods of reading them, selectable in the Options II window.

For more detail on the different methods, see Raw files – DNG.

Video files

Imatest can acquire single frames or groups of frames from the video file formats supported by the Matlab VideoReader class.

Video files are recognized by the following extensions:  mov, avi, mj2, mpg, mp2, and m4v. When a file has one of these extensions, the Video Player window is opened.

Imatest Video Player window

This window has a number of options. You can press Play or Stop to see the contents of the file. You can select a frame for analysis by pressing Mark/Unmark Frame. you can select a range of frames by pressing Mark In, then Mark Out. The frames appear in the Selected frames box, which you can clear if necessary. When you have the appropriate frame or frames selected, press Yes, Continue.

Here is a complete list of all formats. We can add formats as required.

All Platforms

AVI, including uncompressed, indexed, grayscale, and Motion JPEG-encoded video (.avi)
Motion JPEG 2000 (.mj2)

All Windows®

MPEG-1 (.mpg)
Windows Media® Video (.wmv, .asf, .asx)
Any format supported by Microsoft® DirectShow®

Windows 7 or later

MPEG-4, including H.264 encoded video (.mp4, .m4v)
Apple QuickTime Movie (.mov)
Any format supported by Microsoft Media Foundation

Macintosh

Most formats supported by QuickTime Player, including:
MPEG-1 (.mpg)
MPEG-4, including H.264 encoded video (.mp4, .m4v)
Apple QuickTime Movie (.mov)
3GPP  3GPP2  AVCHD  DV

Linux®

Any format supported by your installed plug-ins for GStreamer 0.10 or above, as listed on https://gstreamer.freedesktop.org/, including Ogg Theora (.ogg).
Before the Video reader was available, we extracted still frames from video using VLC Media Player by pausing the video on the frame of interest, then pressing Video, Take Snapshot. The save location was set by pressing Tools, Preferences, Video Settings. Once the frame was saved you could read it as a standard still image file (PNG).

Acquisition devices for Imatest

Imatest Master supports direct image acquisition from a large number of devices (in addition to all Imatest file formats). Direct acquisition is supported by three modules, which cover nearly all Imatest measurements:  Rescharts (all resolution charts— slanted-edges, Siemens Star, Log F-Contrast, Spilled Coins (Dead Leaves), etc.), Multicharts (a great variety of color and grayscale charts), and Uniformity Interactive (most flat-field measurements).

image_sensor_settings_dropdownEach of these modules has a Reload button, which causes the image to be continuously updated in realtime. This allows you to make adjustments on the system and see the effects immediately.

Settings in the Settings dropdown menu
of the Imatest main window

Image acquisition settings in the Settings dropdown menu, shown on the right, are used to select the acquisition device and to make certain settings. The Device Manager, shown below, is the interface to the Matlab Image Acquisition toolbox.

ON Semi Devware

Described in Imatest with DevWare.  You need to download and install the ON Semi Devware software. Both Devware and Imatest need to be started in administrator mode.

Omnivision

Described in Omnivision Quickstart for Imatest.

Android Camera Interface

Described in Android Camera Interface for Imatest IS.

Image Acquisition toolbox

Prior to acquiring images from devices supported by the Matlab Image Acquisition toolbox, the Device Manager should be opened by clicking the button on the lower-right of the Imatest main window, or from the settings dropdown menu of the Imatest, Rescharts, Multicharts, and Uniformity Interactive windows. A list of devices appears on the upper-left, and settings for the selected device appear below it.

Devices 2-7 in the Device List, which appear even when the devices are not present, are supported by custom Imatest code. The last four (DeckLink Studio 4K, Blackmagic WDM Capture, Microsoft LifeCam VX-7000 and DeckLink Video Capture) are available devices (namely a Microsoft webcam and a Blackmagic DeckLink Studio 4K framegrabber) detected by the Image Acquisition toolbox.

The image is blank when the Device Manager is opened. It appears once Start Preview has been pressed. Once you press Save, you can acquire the image with any of the three modules that support direct image acquisition— Rescharts, Multicharts, or Uniformity Interactive, and you can continuously refresh the display using the Reload button.

 

device_manager2

The Imatest Device Manager

The Supported image acquisition hardware page has a list of supported devices and interfaces. More can be found on the Matlab Image Acquisition Toolbox Hardware Support page.