| My Account | Cart Contents | Checkout |
How Imatest API/EXE works
Imatest API/EXE is a set of standalone programs initiated by DOS calls from the test system. The programs have the same functionality as the corresponding modules in Imatest Master, but they operate without user intervention, making them suitable for use in automated systems. They are represented by the blue box in the lower right of the figure below.

The test system interacts with the API/EXE programs through files specified in the DOS command line: the primary inputs are an image file and an INI control file (created and saved by Imatest Master during setup). The output is data files in XML or Excel-readable .CSV format. Figures can be generated and saved if desired.
Although Imatest API/EXE operates independently of Imatest Master, we strongly recommend that API/EXE users have at least one Imatest Master installation on site.
Installing Imatest API/EXE
When you purchase Imatest API/EXE or request a 30-day trial we will send you details on how to download the installation files. A typical file name is colorcheck-04-02-07.exe, where 04-02-07 is the release date. The trial expires on the same date of the following month. (This naming convention may change in future releases).
Installation: Install the module by double-clicking on the installation file name in Windows Explorer. Then either register the module (if you purchased it) or make sure Imatest Studio or Pro is registered on your computer (for the trial version).
Registering API/EXE modules: Double-click on register_imatest.bat in the Imatest installation folder (C:\Program Files\Imatest\ in English language installations). Fill in the Name, Company, E-mail, and Password fields, keeping API in the program field, as shown on the right, then press .
Registration for trial version: Can be done in two ways. (1) Install Imatest and register it using the normal procedure: Click Help, Register, then fill in the fields and press . (2) Double-click on register_imatest.bat in the Imatest installation folder. The dialog box shown on the right appears. Fill in the fields and select Imatest in the program field, then press . The 30-day trial version will work with an Imatest Studio or Pro password.
Path: You should add three folders to the system path if they are not present. In Windows XP,
- Open the Control Panel.
- Double-click on System.
- Click on the Advanced tab in the System Properties window (Advanced system settings in Vista).
- Click on . If Matlab is installed on your system, see the Path conflicts box, below.
- Select PATH in the User variables... window.
- Click on .
- Check to see if the three folders listed below are included in the Variable value field for Path.
;%ProgramFiles%\Imatest;%ProgramFiles%\Imatest\bin\win32;%ProgramFiles%\Imatest\toolbox\matlab
If they are not there, add them to the Variable value field. (You may copy and paste.) - %ProgramFiles% is an environment variable that represents the system default program installation folder. It is equivalent to C:\Program Files in English-language installations. This folder has a different name in non-English installations, for example, C:\Programme in Deutsch, but %ProgramFiles% should be consistent for all languages. Alternatively, you may use the actual folder names.
;C:\Program Files\Imatest;C:\Program Files\Imatest\bin\win32;C:\Program Files\Imatest\toolbox\matlab (English-only)
After you add the folders, be sure the Path list is well-formed— that it consists of proper folder names separated by semicolons (;). - Click on , , to close the System window.
Path conflicts
If you receive such a message, you can try two solutions. 1. Alter the Path environment variable in System variables, located below User variables in the Environment Variables window. Be sure that the three folders listed above appear before the similar folders for the installed version of Matlab. This may involve some careful copying and pasting. Be sure to check the path carefully before you click . 2. Initiate API/EXE programs using the second method shown below: call a DOS BAT file, which sets the path and calls the command line. (Do this instead of directly calling the command line.) This often resolves difficult conflicts. |
Setting up API/EXE
Set up the test system (lights, camera, etc.) and photograph a test chart lighted and framed as it would be in the actual tests.
Save the image in a standard file format. It should have the same pixel count as the actual test images.
Analyze the image using (GUI-based) Imatest Master.
When the settings are correct— when the ROI (region of interest), the calculation details, and the output files and folder locations are what you need for production— press (or Settings, Save Settings...) in the Imatest main window. This allows you to save the control information for Imatest API/EXE in a named .INI file, which can be viewed and edited with any standard text editor. Be sure to save it in a convenient, accessible folder. The contents of .ini files are largely self-explanatory. Here is a sample.
[sfr]
nht_save = 2052
nroi = 2
nwid_save = 3076
roi_mult = 1606 931 1735 1149;334 1693 466 1912
aper =
CA = Min
camera =
cyclesper = Max
cyclesper_value = 1
foclth =
gamma = 0.5
The INI file is divided into sections that start with a bracketed name. [sfr], [q13], [colorcheck], [distortion], [uniformity] are the sections for the five programs that comprise API/EXE. Of the remaining sections, only [api] (described below) affects API/EXE operation.
INI file: more detail
General settings Press Settings, API options in the main Imatest window to open a dialog box that sets options that only affect API programs— they do not affect regular Imatest operation. These options are written into the INI file.

Checking Always save then delete figures makes sure all figures are closed at the end of the run, no matter what the other settings indicate.
Checking Never display progress bars and warning messages disables these graphic displays. These settings affect the contents of the following lines in the INI file.
[api]
nomsg = 1
savedel = 1
These lines can be edited in the INI file using any text editor; the API Options box is merely a convenience. Certain other options in the [imatest] section may be of interest to API users.
[imatest]
readexif = 1 (Reads EXIF data from JPEG images when set to 1; readexif = 0 turns off EXIF read.)
Figures The INI control determines which figures are generated and saved. Any figures that aren't needed they should be turned off for speed. Most are set to either Min (figure off) or Max (figure on), but some (noted in the table below), are set to 0 (figure off) or a number >= 1 (figure on, depending on conditions). These parameters can be set using a text editor, but it's usually more convenient to uncheck the appropriate boxes in the input dialog box prior to saving the INI file.
| [Section] (module) | Plot Name |
Plot or CSV/XML file | save_file_list index |
| [sfr] | cyclesper | MTF in cycles/(pixel or distance) | 1 |
| LWPH | MTF in LW/PH | 2 | |
| CA | Chromatic Aberration | 3 | |
| shannon | Shannon capacity | 3 | |
| CSV output file (detailed results) | 6 | ||
| XML output file (detailed results) | 7 | ||
| SFR_cypx.csv (summary with Cycles/pixel) | 4 | ||
| SFR_lwph.csv (summary with LW/PH) | 5 | ||
| [sqf] (SFR) | SQF | SQF (Subjective Quality Factor) SQF is in its own section, but affects SFR. |
8 (in [sfr]) |
| [q13] (Stepchart) | pltpix | Patch levels and noise (First figure) | 1 |
| pltnoise | Density response, noise, Dynamic range (Second figure) | 2 | |
| pltallch | Density response details (all colors) (Third figure) | 3 | |
| CSV output file (detailed results) | 4 | ||
| XML output file (detailed results) | 6 | ||
| [colorcheck] | pltones | Grayscale tonal response and noise (First figure) | 1 |
| pltnoise |
Noise detail (Second figure) | 2 | |
| pltaberr | a*b* error plot (Third figure) | 3 | |
| pltcolor | Color analysis (Fourth figure) | 4 | |
| CSV output file (detailed results) | 5 | ||
| XML output file (detailed results) | 6 | ||
| [distortion] | distfig | Distortion figure (0 or 1) | 1 |
| dispcorr | Corrected image (if 1, displays if cropped; if 2, always displays) |
2 | |
| outs | Intersection point figure (0 or 1) | 3 | |
| CSV output file (detailed results) | 4 | ||
| XML output file (detailed results) | 5 | ||
| [uniformity] (Light Falloff) | contour | Light falloff contour plots (pixels and f-stop) (0 or 1) |
1 (pixels) 2 (f-stop) |
| shading | Color shading plot (0 or 1) | 3 | |
| detail | Noise detail plot | 4 | |
| CSV output file (detailed results) | 5 | ||
| XML output file (detailed results) | 6 |
The rightmost column in the above table is the index of array save_file_list, which is included in each module's section ([sfr], [q13], [colorcheck], [distortion], and [uniformity]). This index indicates which output figures and files to save. It is generated by the Save dialog box (shown on the right for SFR; Note that the order of the indices may differ from the figure.) For example,
directs the SFR module to save the MTF plot in cycles/(pixel or distance) and the CSV output file that contains detailed results. Another important variable that appears in the sections for the five modules is closefigs. If closefigs = 1, figures will be deleted after being saved. |
![]() |
Some specific settings
[SFR]
roi_mult contains the coordinates of the region(s) of interest, four entries per region: Left, Top, Right, Bottom (L T R B, with the number of regions specified by nroi). Units are in pixels from the top-left of the image. Note that this is different from the order displayed on the SFR Edge/MTF figure: L R T B.
DOS Command line call
Imatest API/EXE programs are initiated by one of two methods.
The first and simplest method is a direct DOS command line call, which has the following form.
c:\program files\imatest\sfr.exe param-1 param-2 param-3 param-4 param-5
Ths second method is to create and call to a DOS BAT file, which sets the path and calls a DOS command line. This may be needed when the first method fails, for example, when a path conflict is difficult to resolve (which may happen in installations that contain newer versions of Matlab than the one used to compile Imatest). The call to the BAT file has the form,
pathname\batfilename.bat
where batfilename.bat contains lines of the following form.
path="%ProgramFiles%\Imatest;%ProgramFiles%\Imatest\bin\win32;%ProgramFiles%\Imatest\toolbox\matlab;%path%"
c:\program files\imatest\sfr.exe param-1 param-2 param-3 param-4 param-5
The first three parameters (param-1 − param-3) are required. The fourth is optional but strongly recommended and the fifth is optional. The program name and parameters 2-5 should contain full path names to minimize the likelihood of error.
| Param-1 | -1 closes the DOS window and all figures when the program terminates. For normal operation of API/EXE programs. -2, -3, and -4 are for debugging. -2 keeps the DOS window open after the program terminates. -3 closes the DOS window and all figures when the program terminates and opens the error log file if an error is detected. -4 keeps the DOS window open after the program terminates and opens the error log file if an error is detected. |
| Param-2 | Image file name. The full path name should be used, e.g.,"c:\program files\imatest\API\Stepchart_DR_Canon_G2.JPG"in the example below |
| Param-3 | Folder where the API/EXE and other programs are located. ( "c:\program files\imatest" in the example below, which is typical of English language systems). The C:\Program files folder has different names in different languages, for example, C:\Programme in German. The name can be viewed by entering set %ProgramFiles% in a DOS window.) |
| Param-4 (optional*) | .ini control file name. If omitted, it defaults to imatest.ini in the same directory as sfr.exe."c:\program files\imatest\API\stepchart_DR_canon_G2.ini" in the example below.) We strongly recommend including it. |
| Param-5 (optional) | folder where results are written. If omitted, it defaults to subfolder Results in the directory that contains the image file. ( "c:\program files\imatest\API\Results" in the example below.) |
*Always use these fields until further notice. |
|
We may add additional parameter-value pairs on user request.
If field names contain blanks, they should be enclosed in quotation marks ("). We recommend always enclosing all fields, including the program call, in quotation marks, except for parameter 1 (which must be -1). Example:
"c:\program files\imatest\stepchart.exe" -1 "c:\program files\imatest\API\Stepchart_DR_Canon_G2.JPG" "c:\program files\imatest" "c:\program files\imatest\API\stepchart_DR_canon_G2.ini" "c:\program files\imatest\API\Results"
Calling API/EXE from Matlab
DOS commands can be called from Matlab by statements of the form,
dos('command')
system('command')
!command — or —
!command & (opens and displays results in a separate DOS window)
where command is a dos command string, which can take the form shown in the example above. Dos or system are recommended.
If you are running Matlab 6.5.1 (the same version used by Imatest), a direct DOS command line call (illustrated above), should work fine. But if you are using a newer version of Matlab (7+), the second method, a call to a DOS BAT file (also illustrated above), may be required to avoid path issues. The following code creates and runs a bat file (sfr_batest.bat). It has been tested with Matlab 7.4.0 (R2007a).
fbat = fopen('c:\imatest\matlab\sfr_battest.bat','wt');
fprintf(fbat,['path="%%ProgramFiles%%\\Imatest;%%ProgramFiles%%\\Imatest\\bin\\win32;' ...
'%%ProgramFiles%%\\Imatest\\toolbox\\matlab;%%path%%"\n']);
fprintf(fbat,['"c:\\program files\\imatest\\sfr.exe" -1 "c:\\imatest\\data_SFR\\Canon_17-40_24_f8_C1_1409.jpg" ' ...
'"c:\\program files\\imatest" "c:\\Imatest\\matlab\\Results\\Canon1740_ctr.ini"\n']);
fclose(fbat);
dos('c:\imatest\matlab\sfr_battest.bat');
% !c:\imatest\matlab\sfr_battest.bat &
%% and \\ are escape sequences that cause single % and \ characters to be written. File sfr_battest.bat contains the following two lines:
path="%ProgramFiles%\Imatest;%ProgramFiles%\Imatest\bin\win32;%ProgramFiles%\Imatest\toolbox\matlab;%path%"
"c:\program files\imatest\sfr.exe" -1 "c:\imatest\data_SFR\Canon_17-40_24_f8_C1_1409.jpg" "c:\program files\imatest" "c:\Imatest\matlab\Results\Canon1740_ctr.ini"
Testing Imatest API/EXE
Several test files (image files, INI control files, and DOS BAT files) are available for testing and verifying API/EXE installations. The image files can also be used with Imatest Master. Right-click on the file names in the table below to download the files. We recommend saving them in subfolder API of the Imatest installation folder: C:\Program files\Imatest\API (in English language installations) or in the equivalent in other languages (for example, C:\Programme\... in German). For testing we recommend setting the first parameter in the DOS call to -4 (keep the DOS window open and display the error log if an error occurs).
Downloadable test images |
|||
Module |
Image file |
INI & BAT files | Description |
| Webcam image of high and medium contrast custom charts created by Test Charts and printed on an Epson R2400 printer: these can have larger regions of interest (ROIs) than the ISO 12233 chart below. | |||
| Webcam image of ISO 12233 chart. At this distance the available regions of interest are very small. | |||
| Webcam image of the Kodak Q-14 grayscale and GretagMacbeth ColorChecker. | |||
| stepchart_DR_canon_G2.ini stepchart_DR_canon_G2.bat |
Image of the Stouffer T4110 transmission test chart taken with the Canon Powershot G2. Excellent dynamic range measurement. | ||
(image in Colorcheck, above) GMB_Q-14_webcam.jpg |
Webcam image of the Kodak Q-14 grayscale and GretagMacbeth ColorChecker. | ||
| 12-patch OECF chart (for API and Imatest Master only ). Available from Applied Image. | |||
| Image of Kodak Q-14 chart with "black hole" cavity for measuring veiling glare (susceptibility to lens flare) | |||
distortion_webcam_a.jpg |
Webcam image of distortion grid. | ||
uniformity_1600_JPEG80.jpg |
Image of nearly uniformly illuminated surface taken with the Canon 10-22mm lens on the EOS-20D, f/4.5, 22mm, ISO 1600. | ||
To use these test files,
- Make any necessary changes to the saved ini and bat files using a text editor. You'll need to update folder names if Imatest is installed in a folder other than C:\Program files\Imatest or the test files (above) have been saved in a folder other than C:\Program files\Imatest\API. You only need to edit folder names in the appropriate section of the ini file, which follows the module name enclosed in brackets: [sfr], [colorcheck], [q13] (for Stepchart), [distortion], or [uniformity] (for Light Falloff).
- Open a DOS window (Start, Run..., cmd; Start, All Programs >, Accessories >, Command Prompt).
- Change to the directory where the files are located. Typically, enter
cd C:\Program files\Imatest\API. - Run the bat file by entering the file name, omitting the bat-extension. For example,
stepchart_DR_canon_G2 - Verify the results by looking in the folder where resuts are stored, typically subfolder Results of the folder that contains the image, ini, and bat files. If you found errors that aren't obvious and aren't covered in the Troubleshooting page, please contact us.
Error handling
Imatest API/EXE modules return a value of 0 if they terminate correctly or 1 or larger if they terminate in error.
If an error is detected, a message is
- appended to the error log file, which has the name of the form module.log (sfr.log, colorcheck.log, stepchart.log, distortion.log, or uniformity.log), and is is located in %APPDATA%\Imatest.
- written to the CSV and/or XML file that would otherwise contain the results of the run. For the example above,
"c:\program files\imatest\stepchart.exe" -1 "c:\program files\imatest\API\Stepchart_DR_Canon_G2.JPG" "c:\program files\imatest"
"c:\program files\imatest\API\stepchart_DR_canon_G2.ini" "c:\program files\imatest\API\Results"
if a CSV output file were called for, it would be c:\program files\imatest\API\Results\Stepchart_DR_Canon_G2_summary.csv ;
if an XML output file were called for, it would be c:\program files\imatest\API\Results\Stepchart_DR_Canon_G2.xml .
APPDATA is a DOS environment variable whose value can be found by opening a DOS window (you can double-click start-dos.bat in the Imatest folder), and typing
set APPDATA (Returns the folder name corresponding to APPDATA)
--or--
dir "%APPDATA%\Imatest"
APPDATA has values of the form
- C:\Users\your name\AppData\Roaming in Windows Vista.
- C:\Documents and Settings\your name\Application Data in Windows XP.
To facilitate debugging, the log file will be opened in Notepad if an error is detected and the first parameter of the API/EXE DOS call is -3 or -4.
Lines in the log file have the format,
[Date Time], file_name, error_message
Example:
[05-May-2007 23:34:08], c:\Imatest\data_distortion\distgrid101.jpg, Inconsistent Vert lines 17 det.; 18 avg. Incomplete line?
We are constantly working to improve the robustness of Imatest algorithms to minimize the occurrences of errors, which are typically caused by poor region (ROI) selections or poor quality images.
| Digital Image Quality Testing - Copyright © 2008 Imatest LLC |

