Documentation – Current v24.2

ISP/Camera Simulator (ISPsim)

Current Documentation

All documentation versions

Input files – Opening ISPsim – Settings – Image processing blocks – Sharpening – RunningProcessing – 
Side-by-side displayDisplays and analysis – Saving bayer raw (remosaiced) images – 
Optical Character Recognition (OCR) – Face and People Detection 

The Imatest ISP (Image Signal Processing) Simulator module, ISPsim, simulates ISP pipelines, and with some limitations, complete camera systems. It evolved from the Imatest Image Processing module, but is much more powerful and flexible, allowing operations to be performed in arbitrary order. ISPsim can greatly speed up the development of image processing pipelines.

ISP input includes

  • Bitmap test charts produced by the Imatest Test Charts module, 
  • Bitmap test chart files that have been processed to include lens degradations and stray light by lens design programs, such as Code V,
  • Raw (converted raw) images acquired from cameras with minimal processing (no sharpening, noise reduction, white balance, etc.). Highly processed images (most consumer camera JPEGs) are not recommended.

ISPsim processing includes 

  • Camera and lens image degradations, such as noise, fog (veiling glare), and blur, 
  • Image adjustments, such as exposure (and gain), gamma, and Beyer demosaicing/mosaicing, 
  • image enhancements, such as applying a Color Correction Matrix, tone mapping (used in High Dynamic Range (HDR) imaging), Sharpening (standard or Unsharp Mask (USM)), and bilateral filtering,
  • ability to simulate motion blur, low light conditions, and more.

ISPsim results

ISPsim includes an accurate image sensor noise model, based on just two measured parameters (well capacity at maximum signal and dark noise). No radiometric calculations are needed, though they can be useful for determining a camera’s absolute sensitivity. They may be added in the future.

ISPsim is expandable. Processing blocks will be added based on customer requests. The current set of blocks is primarily focused on operations that affect visible and measurable image quality. 

ISPsim  can operate on batches of images, automatically reading, processing and saving images in the batch.

ISPsim input files

ISP input can come from any image file, raw or demosaiced, that is readable by Imatest and listed in Image file formats and acquisition devices. Although ISPsim can work with any image, test chart images produce the most useful quantitative results. There are three major sources of input files.

Test Charts program — The most convenient source of test chart images is the Imatest Test Charts program. Here is an example, illustrating settings for creating a 2400×1600 pixel Enhanced eSFR ISO 2017 chart.

Test Charts window for the Enhanced eSFR ISO 2017 chart

Although we recommend reading the documentation for Test Charts and SVG Test charts, this page should contain enough information to get you started. You can also download the 2400×1600 PNG image (with added color patches) that was used for developing and testing ISPsim

Test Charts lets you create SVG (Scalable Vector Graphics) or bitmap (TIFF or PNG) chart files that can be used for printing physical charts or for analyzing chart images. It contains a great many chart types, selectable in the Pattern dropdown menu (top-left) as well as a great many options. Chart patterns that have continuous tones (such as the sinusoidal Siemens Star) must be created as bitmap files, sized for printing or for Imatest analysis. SVG files can be opened by Inkscape (an excellent free program) for printing in any size or conversion to PNG bitmap files (which can also be done within Test Charts). eSFR ISO (ISO 12233-2017) charts, which are normally printed large, are created as SVG files, but can also be saved bitmap (PNG) files by checking the Save PNG (bitmap) file box, just below the chart image, and specifying the desired image height in pixels.

Because bit depth for PNG images converted from SVG is limited to 8-bits (256 levels), we recommend keeping (display) Gamma = 2.2 (the inverse of the encoding gamma used in most common interchangeable files) to maximize the dynamic range. Some settings are hidden in dropdown menus. We recommend selecting eSFR LogWedge max = 4000 LW/PH in the Settings dropdown menu. 

When your settings are complete, press  Create Test Chart , and save the files (you’ll get both SVG and PNG) in a convenient location.

Lens design programs — such as Code V let you process chart images, degrading them (adding blur, chromatic aberration, vignetting) using a realistic lens model. The chart images can be created with the Imatest Target Generator, which is a back-end for Test Charts, converting SVG charts to bitmap files. Charts for input to lens design programs must have gamma = 1 (linear gamma). When a lens design program has been used, the (blur) filter blocks won’t be needed, unless you need to simulate an anti-aliasing (optical lowpass) filter.

Images acquired from cameras — Raw or minimally-processed images,  converted to RGB with LibRaw or ReadRaw, work well. These include the actual images from development systems that need to be tuned. Blur and noise are already present in these images, so (blur) filter and noise blocks won’t be needed.

Most JPEG images from consumer cameras should be avoided because they are already heavily processed, including complex tonal response curves (with “shoulders”) and nonlinear and nonuniform bilateral filtering, making it difficult to obtain useful results.

Opening ISPsim

Press ISP Simulator in the the Utility dropdown menu or in the Utility tab on the right of the Imatest main window. This opens initial ISP Simulator window, which contains basic instructions and has many buttons grayed out (to minimize confusion). The instructions will be periodically updated. To perform an analysis, you will need to

  • read an image file, and
  • make sure you have the correct settings, which are saved from the previous run. You can update them from the ISP Settings window if needed.

The order of pressing Read image file and ISP Settings is irrelevant.

ISP Simulator opening window. Click on image to view full-sized. The text will be updated.

Settings

The settings window lets you set up the analysis: you can select processing blocks, and adjust their parameters and the order of operations. To open the settings window, press the ISP Settings button on the upper-left of the ISP Simulator window. Since ISP settings are saved from the previous run, you may not need to open it. Settings can be made before or after reading an image (but always before for batches of images).

The Settings window contains a large number of processing blocks. Some, like Sharpen or Bilateral Filter, have several associated parameters and are contained inside rectangular frames.  Others, like Exposure or Gain, which have at most one associated parameter, are not displayed inside frames. Their order is not related to the order of operations to be selected.

ISP settings screen

The Image Processing Blocks window, on the upper-right, contains the sequence of operations. Blank lines are intended to make it easy to insert, arrange, and delete entries, and are ignored when the settings are transferred to the main window or processed.

Selecting and ordering image processing blocks

1. Choose a block to include in the image processing pipeline.
2. Adjust parameters — sliders, popup menus, or edit boxes.
3. Use the Set popup menu button next to each block to enter it into the Image Processing Blocks list box on the right. All the Set popups have the same contents: Set, 1, 2, 3, …, 20. Click on the Set popup, then click on the line number where you want the block to be entered. Choosing Set (instead of a line number) cancels the operation.
4. Since the block parameters are copied to the list box, you can reuse blocks by changing their settings and entering them on a different line.
5. The tint of the Set box indicates the status of the block.  White with a green background  indicates that the block has been selected and appears in the Image Processing Blocks list box.   White with a red background  indicates that the block has been adjusted, but not (yet) selected. Press Set then the line number to select it. Press Set then Set (not a line number) to reset the box to  Black/white . In the above window, both the Add and Correct cos4 lens shading popups are  white/red  because they are both affected by the setting; they will be both reset to  Black/White  when one has been selected.
6. The Image Processing Blocks list box contains many blank lines. They are there to make it easy to add and edit lines, and they are ignored when the calculations are performed.
7. The order of the processing blocks can be conveniently edited using the buttons (Insert or Delete (line)Move (line_ up or down, etc.) below the Image Processing Blocks list box.
8. Pressing  OK  saves the settings and closes the Settings window. The selected image processing blocks (with blank lines removed) appear in the ISP Simulator window.
SUMMARY: Settings are made in two steps: (1) Adjust the parameter, and
(2) move it into the appropriate line in the Image Processing blocks box.
Since it’s easy to forget the second step, the Set window is changed to
 White with a red background
 when the corresponding parameter has been adjusted.

For example, Filter 2 (on the left of the settings window) was copied to line 9 by selecting the Set dropdown on the left of the Filter 2 frame, then selecting 9 in the menu (which contains 1-20). In most cases, parameters are copied along with the lock name. Note that there is considerable space in the Settings window to add new blocks. Several are planned, and we are always interested in customer requests.

Image processing blocks

As we indicated, updating the calculations applies image processing blocks in the selected sequence. Depending on the input image source, some of the  degradation or enhancement steps may have been performed prior to entering the image into ISPsim. For example, JPEGs from consumer cameras typically have nonlinear, nonuniform bilateral filters (we don’t recommend them for ISPsim). Noise and filtering (blurring) have already been implicitly applied to images acquired from cameras (i.e., you don’t have to add noise and blur because they are present in the image).

Here is a list of the processing functions currently available (December 2024). Most are standard Matlab functions or custom Imatest code; the Lanman bilateral filter is a user-supplied function from the Mathworks File Exchange. Nonuniformity or nonlinearity are indicated in bold blue. Nonuniform or nonlinear operations are not recommended for image information metric calculations.

Processing block Description Function:
described in link
Input
gamma
Not actually a processing blockInput gamma is critically important for keeping track of the image gamma at each state of the processing. There will almost certainly be errors if it is entered incorrectly. Input gamma is typically 1 for (linear) raw images or around 0.45 (0.5 is close enough) for interchangeable color space images (sRGB, Adobe RGB, etc.) Gamma, Tonal Response Curves, and related concepts
Linearize (equivalent to Gamma target 1, which is recommended) Linearize the image (remove the gamma encoding). Images can be linearized, operations can be applied, then a final encoding gamma can be reapplied near the end of the ISP pipeline. Gamma = 1 is recommended for most processing blocks, such as standard sharpening (the 2D version of the 1D sharpening described on the Sharpening page. Not recommended for USM sharpening.  
Gamma Apply gamma encoding to an image. Gamma can be selected by a slider (shown above) and a popup menu that contains Target and Mult. Important because the input and output may be gamma-encoded (often with gamma ≅ 0.5), but many operations may need to be performed with gamma = 1. For Mult
imageout = imageinputγ. For Target, where the current value of gamma is γ_current ,
imageout = imageinput(γ/γ_current).
Gamma, Tonal Response Curves, and related concepts

Bayer mosaic

Demosaic

Demosaic converts a mosaiced Bayer raw file from an image sensor with a Bayer Color Filter Array (CFA) into a 3-color RGB file using the MATLAB demosaic function. Demosaicing is a complex process that can generate artifacts and affects the Noise Power Spectrum. Bayer raw files can also be demosaiced by the Imatest LibRaw and ReadRaw modules.

Bayer mosaic takes converts a 3-color RGB image into a monochrome, mosaiced pseudo-raw image that needs to be demosaiced to be converted back into an RGB image. It can be useful for studying the effects of demosaicing when ISPsim starts with simulated (RGB) images. It uses a simple, straightforward algorithm (with no artifacts) to convert RGB images into one of the four Bayer alignments: {RGGB, GRBG, GBRG, or BGGR}.

demosaic

Imatest raw processing

Exposure

Gain = 1/Exposure

Gain (set by slider)

Exposure/gain multiplier (gamma = 1 (linear) recommended)

Exposure (a multiplier usually < 1) is typically applied to simulated images before noise is added. It represents an actual change in exposure.

Gain = 1/Exposure is typically applied after noise has been added. Combining these two blocks is equivalent to dividing the Exposure Index (EI; commonly known as ISO speed) by Exposure. This decreases the Signal-to-Noise Ratio. For example, for a base EI of 100, applying Exposure = 0.25 before the noise and 1/Exposure = 4 after the noise is equivalent to increasing the EI to 400.

Gain (multiplier) can be applied at any point in the pipeline. 

 

Add, correct cos4 lens shading

Also called lens “vignetting” (gamma = 1 (linear) recommended)

Adding lens shading can be done for simulated images early in the ISP pipeline, before noise has been added. It doesn’t need to be added for real camera images.

Lens shading can be corrected later in the pipeline, while gamma is still 1.

 
Negative Invert the image, i.e., turn it into a negative. Infrequently used. Best performed on linear images (gamma = 1 (linear) recommended).  
Image degradations: blur and noise.  Often found in images acquired from cameras prior to processing. Operations are generally linear.
Fog (veiling glare)

Fog the image: equivalent to adding flare light or veiling glare.
imageout = fog + (1-fog)*imageinput   fog is Typically a small fraction, <0.2.

Negative values of fog can be used to correct for black level offset. 

 
Gaussian
Filter 1
Blur the image (before applying noise). This simulates lens blurring. imgaussfilt:  2-D Gaussian filtering of images with parameter sigma.
Noise  (Gaussian) Add noise to the image. Will be filtered by Gaussian Filter 2. imnoise:  Add noise to the HSV V channel. Parameters sigma [] and Luma noise [].
Gaussian Filter 2 Blur the image. Affects the noise spectrum if applied after noise. The spectrum for σ = 0.5 is similar to output of demosaicing (in raw conversion), which decreases noise from 1 to 0.5 at Nyquist. imgaussfilt:  2-D Gaussian filtering of images with parameter sigma.
Tonal enhancement:  Correct colors or apply one of three tone mapping algorithms, used for displaying High Dynamic Range (HDR) images. Tonal response may be highly nonlinear.
Color Correction Matrix (CCM) Apply a Color Correction Matrix (CCM), which can be calculated and saved in Color/Tone. using the processed image from ISPsim at the stage where the CCM is to be applied (usually near the end of the ISP pipeline). The Set CCM button to the right of the CCM checkbox opens a window (shown on the right; click on thumbnail to view full-sized) that lets you set up the matrix (read it from a file or paste it from the clipboard and select options (linearization, etc.)). Color Correction Matrix describes the CCM, which is calculated in Color/Tone.
Tone mapping

Render high dynamic range (HDR) image for viewing in displays with limited dynamic range. Tone mapping is a technique used to approximate the appearance of high dynamic range images on displays with a more limited dynamic range. Nonuniform and nonlinear

tonemap:  Render high dynamic range image for viewing
Local tone mapping Alternative tone mapping algorithm for HDR images using Laplacian filtering. Has a different set of adjustments. Produces different results (more saturated images). Nonuniform and nonlinear localtonemap 
Contrast-Limited Histogram Equalization CLAHE operates on small regions in the image, called tiles, rather than the entire image. Each tile’s contrast is enhanced, so that the histogram of the output region approximately matches the histogram specified by the ‘Distribution’ parameter. The neighboring tiles are then combined using bilinear interpolation to eliminate artificially induced boundaries. The contrast, especially in homogeneous areas, can be limited to avoid amplifying any noise that might be present in the image. Nonuniform and nonlinear adapthisteq:  Contrast-limited adaptive histogram equalization (CLAHE)
Spatial enhancement:  sharpening and/or noise reduction. Output depends on image content— may be highly nonlinear.
Sharpen USM (Unsharp Mask)

Sharpens the grayscale or RGB input image using the unsharp masking (USM) method. Most visible on edges. USM works by subtracting a gaussian blur function from the original image. If threshold > 0, low-contrast regions may not be sharpened. See Wikipedia.

This function is not linear. It caused some inconsistencies with the image information metrics. Designed to work directly on images, which should not be linearized. Nonlinear (a surprise; not indicated in MATLAB documentation)

imsharpen: Unsharp Masking (USM)
Sharpen
Standard

Sharpens the grayscale or RGB input image using a 2D version of the 1D sharpening method described in the Sharpening page. Most visible on edges. It works by subtracting an amplitude-reduced replica of the original image, arranged on a circular locus with radius R, from the original image. 

To maintain linearity, Linearize should be checked. This causes the image to be linearized (gamma-encoding removed) at the start of the calculations. Then sharpening is applied to the linearized image, then gamma encoding is reapplied. Recommended for testing the effects of sharpening on image information metrics, such as SNRi or Edge SNRi.

Because standard sharpening is not a MATLAB function, we include more explanation in the box below.

Custom Imatest function. 

Either USM or Standard sharpen can be applied (but not both).

Bilateral filter

Bilateral filtering was proposed by Tomasi and Manduchi in 1998 as a non-iterative method for edge-preserving smoothing.

    1. Half-width w is the half-size of the Gaussian bilateral filter window.
    2. sigma (range) is the spatial-domain standard deviation.
    3. sigma (domain) is the the intensity-domain standard deviation.

imbilatfilt (MATLAB)

bfilter2 (from the Mathworks File Exchange): 

 

A complete (though elementary) Image Processing pipeline can be simulated by reading a raw or minimally processed image (demosaiced by ReadRaw), then applying operations such as Color Correction Matrix (which also applies a gamma curve), sharpening, and a bilateral filter (a simple example— there are many options). 

 

Sharpening (standard; not USM) is an Imatest (not a MATLAB) function, designed to maintain linearity.

As we mentioned above, this is a 2D version of the 1D sharpening method described in the Sharpening page. It was created when we were trying to determine if USM, which is implemented with the MATLAB imfilter function, is nonlinear (it is). It is also closer to typical camera sharpening than USM, which is more computationally intensive.

For sharpening radius R and amount A, define ksharp = A/(A+1). The filter kernel is a 2R+1×2R+1 matrix H (units of pixels), calculated by (1) setting each entry at a distance r from the center to H(r) = max(|R-r|,0), (2) setting H = H/∑H, then setting the entry at the center, H(R+1,R+1) = 1.

For a filter with Radius = 2, Amount = 3 (strongly sharpened), the 5×5 kernel is

-0.0092 -0.0409 -0.0535 -0.0409 -0.0092
-0.0409 -0.0222  0      -0.0222 -0.0409
-0.0535  0       1.0000  0      -0.0535
-0.0409 -0.0222  0      -0.0222 -0.0409
-0.0092 -0.0409 -0.0535 -0.0409 -0.0092

Standard sharping should be used with Linearize γ for gamma-encoded images. It is a linear operation (as long as excessive sharpening doesn’t saturate the image). 

 

Running ISPsim

Read an input image file if it hasn’t been read in already. It doesn’t have to be a test chart; any pictorial image can be used. The sequence of reading an image file and updating the settings doesn’t matter. Most types of image can be used, though as we indicated above, we don’t recommend highly processed JPEGs from consumer cameras.  

Batches of files  If several files are selected, they will be read, processed, and automatically saved in a batch using the stored settings. (Most outputs won’t be displayed, but of course you can open the saved files for examination.) The dialog box shown on the right will open after you select the files. Files named root_file_name.ext will be saved as root_file_nameext-ispsim.png.

Before running a batch of images you should run a single image to be sure the settings are correct. Note that the batch calculations are not optimized for speed, so batch processing, which typically takes several seconds per image, is not suited for high volumes of images.

Process the image using Update calculations or another of of the buttons in the Calculation group (light blue box) on the left of the ISP simulator window. The processed image appears. Alternatively, you can press Read image file (2) to read a file with the same scene content but different image processing to compare with the first image.

Processed image in ISPsim

Calculations can be updated by pressing buttons in the Calculate group, on the left.

Update calculations Starting with the input image, process each block shown in the listbox on the upper-left. Display the results when processing is complete.
Input Restore the input image view.
Display results for 1s during updates (checkbox) Display the results for 1 second after each block when running Update calculations.
Step through calculations Step through the calculations manually, pushing the button for each block. Cumulative results are displayed after each block.
Step & show single block Step through the calculations manually, pushing the button for each block. Results for the current block-only (not the cumulative results) are displayed after each block.

Side-by-side view

The side-by-side view allows you to compare the input and processed images side-by-side, i.e., right next to each other. Click the Side-by-side view checkbox just below View input or View processed (on the left, below the image). When the box is first checked the two images are displayed in their entirety. If you crop one, the other will have the identical crop. This makes for meaningful comparisons.

Here is the ISP Simulator display for the eSFR ISO chart image (cropped and shown in the Side-by-side view, input on the left; processed on the right). The input image is straight out of Test Charts. The processed image had had blur, noise, and sharpening added. 

ISP Simulation window showing eSFR ISO chart image displayed in Side-by-side view. 
Input image on left; processed image on right. Zoomed in (for display-only)

 

Cropping and zooming— There are two distinct types of crop/zoom operation: zooming for display-only and cropping for calculations (as well as display).

  • Zooming (cropping for display-only) is performed by the standard Matlab procedures: clicking on the image (to zoom in), dragging and clicking to select a region, or by double-clicking (to zoom out). These does not affect calculations such as MTF.
  • Cropping for calculations as well as display is performed by pressing the Crop button in the Analysis and View area below the image. This brings up the standard Imatest coarse and fine crop windows. This approach affects calculations such as the MTF curve (which is image-dependent for several processing blocks) or the mean SSIM calculation (though the detailed SSIM plot is unaffected). Pressing the Crop button enables the Zoom out and Zoom to crop buttons on the lower-right of the window. To remove the crop, press the Crop button and select the entire image.

Utilities

Several utilities are available in the dropdown menus at the top of the ISP Simulator window. (There is little room for added buttons in the window.)

File Display and/or Save screen Display the screen in an image viewer (Irfanview recommended) and optionally save it. This function is in several interactive modules.
  Save image Save the processed image. Normally images will be saved in full precision (except if 8-bit max (below) is checked).
  Save pseudo-raw/remosaiced image Save the image in a pseudo-raw (remosaiced) or special format, including Bayer, RCCC, or specific channel can be selected. Many options. See Synthetic RAW images.
  Save image as monochrome Save the image (which may be color) as a monochrome image.
  Swap Endian (16, 32-bit input) Swap the order of bytes within pixels (useful in rare instances where they are incorrect)
  Save image files with 8-bit max precision Unchecked (off) by default. If set, images will be saved in 8-bit precision. (This should normally be unchecked).
  Save image as HDR Save the image in HDR (High Dynamic Range) format
View Colorbar (grayscale or color) Grayscale or color: Used in SSIM and PSNR displays. The colors in the color bar can be changed in Options II.
  Crop Lets you select a crop for image analysis operations (MTF, SSIM, etc.) Same as the Crop button in the Analysis and View area.
Analysis Most functions duplicate buttons in the Analysis and View section, but there are several additions.
  Image Statistics Call the Image Statistics module for viewing image statistics such as histograms and cross-section profiles.
  Radial Geometry Call the Radial Geometry module, which can return an image with added or corrected optical distortion, lateral chromatic aberration, and/or rotation.
  OCR Optical Character Recognition using Matlab’s OCR function
  Detect faces Uses the Matlab CAMShift routine, described below.
  Detect people Uses the Matlab detectPeopleACF routine, described below. Less effective than Face detection.
Help Open web pages with descriptions of various ISP Simulation blocks.

Results display and analysis

The display is controlled by buttons below the image or by the Analysis dropdown menu. You can choose between a visual display of the Input or Processed image or a calculated display (an analysis comparing the input and processed images).

Results display summary: Selected by buttons below the image or Analysis dropdown menu
Input Display the input image (1)
Processed Display the processed image (2)
MTF Display the MTF of the processed / input image as a function of spatial frequency. Sensitive to cropping.
MTFnn Display a polar plot of MTF70-MTF10 (spatial frequencies where MTF is nn% of low frequency value)
MTFnnP Display a polar plot of MTF70P-MTF10P (spatial frequencies where MTF is nn% of peak value)
SSIM Display the Structural Similarity Index, which is discussed in detail on the page for the SSIM module. Better correlated to visual differences (degradations) than PSNR.
PSNR & DIff Display the Peak Signal-to-Noise Ratio and the difference between images.
OCR Optical Character Recognition results using Matlab’s OCR function
Detect faces Face detection results using the Matlab CAMShift routine.
Detect people People detection results using the Matlab detectPeopleACF routine, described below. Less effective than Face detection.

 

image_processing_displays

The View input button on the left, just below the image, toggles between View input (when the processed image is selected) and View processed (when the input image is selected). This enables rapid visual comparison of the two images. The zoom setting is preserved when you switch images. The View input/processed button performs the same functions as the Input and Processed buttons in the Analysis and View area. The other buttons in this area display calculated results.

SSIM displays the Structural Similarity Index, which is discussed in detail on the page for the SSIM module. It’s primary use is in measuring the visible effects (i.e., degradation) of image compression from saving files (for example, JPEGs of varying quality) and from data transmission.

MTF (Modulation Transfer Function) calculates the transfer function between the Processed and Input images using a 2D Fourier transform similar to the calculation in the Random module, but with one important difference. Unlike the Random module, where the scaled Power Spectral Density in gray areas to the left and right of the active area (the random/Spilled Coins/Dead Leaves pattern) is subtracted from the total power spectral density of the active area to remove most of the noise, there is no noise reduction. Hence this MTF measurement is extremely sensitive to noise.

image_processing_MTF_noisyMTF for noisy Gaussian-filtered image after Unsharp Masking

The high frequency rolloff is the effect of Gaussian filter 2, which is applied after the noise has been added (and hence shapes the spectral power of the noise).

You can see the MTF for Unsharp Mask (USM)-only (in this case with Radius = 1.5 and Amount = 2.5) by unchecking Noise (gaussian) and Gaussian filter 2 in the ISP Simulation area to the left of the image, then pressing Update calculations. Unsharp Masking has a different spectral response from the type of sharpening described in the Sharpening page: It’s response is not cyclical. It rises to an asymptotic level of Amount+1 and stays high.

This is a good example of how the ISP Simulator can be used to explore the effects of processing blocks on both appearance and measurements.

image_processing_MTF_USMMTF for USM (Unsharp Mask: Radius = 1.5; Amount = 2.5)

 

Saving Bayer raw (remosaiced; undemosaiced) images

By clicking File, Save pseudo-raw (undemosaiced) image (after a file has been read), you can save the image in a synthetic Bayer RAW format as well as one of several other formats. The output can be a standard image file format or pure binary. A dialog box opens that allows a number of options.

Mosaicing or channel selection  None (Normal color file output), Remosaic (Bayer format), RCCC (Red-Clear-Clear-Clear): R bright, RCCC (Red-Clear-Clear-Clear): R = C/3, Monochrome (Y = luminance), Monochrome (mean: equal weights), Red, Green, Blue. For remosaicing (creating Bayer RAW files), Remosaic (Bayer format) would be selected.

Red in RmCn  lets you select one of the four Bayer configurations.

Gamma adjust  lets you adjust the gamma of the output curve. Keep it at 1 for no change. Use 2 (or 2.2) to go from a typical color space gamma to linear (gamma = 1).

Save file format  lets you select a standard image file format (PNG, JPG (90% quality), TIF (large), BMP, Binary 8-bit, or Binary 16-bit. The binary files can be read into Generalized Read Raw.

Green channel emphasis  lets you emphasize the green channel so that the synthetic RAW image resembles actual raw images, which typically are strongest in green. Several Blue/Red levels are available.

When you select Save, a dialog box lets you select the location and file name. The default is root_file_name_png (with the selected extension).

Optical Character Recognition (OCR)

OCR has been added in Imatest 5.0, using Matlab’s OCR function, which is an implementation of Tesseract-OCR. To use it,

  • Read an image containing text of interest.
  • Process the image if required. Processing can consist of image degradations (such as blur, noise, etc.) to see how they affect detection or image enhancements (unsharp mask, bilateral filtering, etc.) to see if detection can be improved.
  • Crop the image to the text region (strongly recommended if significant areas contain features other than text), then
  • Click OCR.

This opens the OCR window and performs a text recognition operation on the crop of the image. Results for the sample image on the right (mildly degraded with Noise (gaussian) = 0.002; Gaussian filter 2 = 0.7) are shown below. You can download this image and experiment with to see how various degradations and enhancements affect OCR performance.

Be forewarned. Matlab’s OCR performance is not impressive. Text that appears to be quite readable does not do well, especially for font sizes under 12 points. Performance is comparable to several free or low-cost OCR programs such as gImageReader (a GUI front-end for Tesseract-ocr) and TopOCR.

 

Sample image: Click for a
full-sized version that can be downloaded.

The left side sample image consists a set of characters (QWERTYUIOPASDFGHJKLZXCVBNM1234567890) of different sizes ranging from 20 to 7 points in normal, bold, and negative bold Calibri font. These are characters used in automotive license plates. The file (here) was created in Microsoft Word. The remainder of the image is a portion of the Enhanced eSFR ISO chart, with wedges and two high contrast squares. These can be used to correlate MTF measurements with OCR performance.

OCR window, showing results for mildly-degraded crop of the sample image

OCR Settings

Character Subset  Results can be improved by entering a character subset to limit the valid output characters (all characters are allowed if Character Subset is blank), then pressing CALCULATE OCR. For the sample image, the subset consists of Latin capital letters and numbers (typical of automobile license places). It makes only a small improvement.

QWERTYUIOPASDFGHJKLZXCVBNM1234567890

Standard OCR does not work very well with license plates. Several license plate detection routines are available in the Matlab File Exchange. We may add one or two if they work well and the license allows.

Display  Text (shown) is the default. You can also select Confidence & words, which shows the Word Confidence and individual word. Here are a few lines from the display.

0.8545   QWERTYUIOPASDFGHJKLZXCVBNM1234567890
0.8361   QWERTYUIOPASDFGHJKLZXCVBNM123456789O
0.9018   18
0.7842   QWERTVU|OPASDF6HJKLZX(VBNM1234567890
0.8339   16
0.7468   QWEKTYUIOPASDFGHJKLZXCVBNM1234567B90
0.8254   14
0.7252   QWERYYUIOPASDFGI-1JKLZX(\/ENM1Z34567E9(!
0.7784   12
0.5777   QWERTYUWDDASDFGHJI(LZXCVBNM113A567E9u
0.6549   11
0.6276   uwEuHu\onAsur:.r<n<.zxn’aNM:23-4ss7s9u
0.7658   m

Copy to clipboard  You can copy the current display into the clipboard for use in text editors or other applications.

Save results  saves the current display.

Variable or fixed width font can be selected in the Settings dropdown menu.

Face and People detection

Face and people detection can be called from the Analysis dropdown menu. Both currently use the Matlab default settings. (We may add an options window in the future.) See

Face Detection and Tracking Using CAMShift  and  detectPeopleACF

Face detection works somewhat better than people detection. Here is an example, using an image shamelessly stolen from http://epaperpress.com/portfolio/columbia.html. The soggy author of Imatest is on the left. Click Update Calculations to remove the annotations (to reset the image).

Example of Face Detection (Imatest author on the left)

Face detection works pretty well much of the time, but seriously… How can you miss Paul and John?

 

 

Input files – Opening ISPsim – Settings – Image processing blocks – Running – Sharpening – 
Displays and analysis – Remosaicing – Optical Character Recognition (OCR) – Face and People Detection 

The Imatest ISP (Image Signal Processing) Simulator module, ISPsim, simulates ISP pipelines, and with some limitations, complete camera systems. It evolved from the Imatest Image Processing module, but is much more powerful and flexible, allowing operations to be performed in arbitrary order. ISPsim can greatly speed up the development of image processing pipelines.

ISP input includes

  • Bitmap test charts produced by the Imatest Test Charts module, 
  • Bitmap test chart files that have been processed to include lens degradations and stray light by lens design programs, such as Code V,
  • Raw (converted raw) images acquired from cameras with minimal processing (no sharpening or noise reduction, etc.). Highly processed images (most camera JPEGs) are not recommended.

ISPsim processing includes 

  • Camera and lens image degradations, such as noise, fog (veiling glare), and blur, 
  • Image adjustments, such as exposure (and gain), gamma, and Beyer demosaicing/mosaicing, 
  • image enhancements, such as applying a Color Correction Matrix, tone mapping (used in High Dynamic Range (HDR) imaging), Sharpening (standard or Unsharp Mask (USM)), and bilateral filtering,
  • ability to simulate motion blur, low light conditions, and more.

ISPsim results

ISPsim includes an accurate image sensor noise model, based on just two parameters (well capacity at maximum signal and dark noise). No radiometric calculations are needed, though they are useful for determining a camera’s absolute sensitivity. 

ISPsim is expandable. Processing blocks will be added based on customer requests. The current set of blocks is primarily focused on operations that affect visible and measurable image quality. 

ISPsim  can operate on batches of images, automatically reading, processing and saving images in the batch.

ISPsim input files

ISP input can come from any image file, raw or demosaiced, that is readable by Imatest and listed in Image file formats and acquisition devices. Although ISPsim can work with any image, test chart images produce the most useful quantitative results. There are three major sources of input files.

Test Charts program — The most convenient source of test chart images is the Imatest Test Charts program. Here is an example, illustrating settings for creating a 2400×1600 pixel Enhanced eSFR ISO 2017 chart.

Test Charts window for the Enhanced eSFR ISO 2017 chart

Although we recommend reading the documentation for Test Charts and SVG Test charts, we will try to provide enough information to get you started. You can also download the 2400×1600 PNG image (with added color patches) that was used for developing and testing ISPsim

Test Charts lets you create SVG (Scalable Vector Graphics) or bitmap (TIFF or PNG) chart files that can be used for printing physical charts or for analyzing chart images. It contains a great many chart types, selectable in the Pattern dropdown menu (top-left). Chart patterns that have continuous tones (such as the sinusoidal Siemens Star) must be created as bitmap files, sized for printing or for Imatest analysis. SVG files can be opened by Inkscape (an excellent free program) for printing in any size or conversion to PNG bitmap files (which can also be done within Test Charts). eSFR ISO charts, which are normally printed large, are created as SVG files, but you can save a bitmap (PNG) file by checking the Save PNG (bitmap) file box, just below the chart image, and specifying the desired image height in pixels.

Because bit depth for PNG images converted from SVG is limited to 8-bits (256 levels), we recommend keeping (display) Gamma = 2.2 (the inverse of the encoding gamma used in most common interchangeable files) to maximize the dynamic range. Some settings are hidden in dropdown menus. We recommend selecting eSFR LogWedge max = 4000 LW/PH in the Settings dropdown menu. 

When your settings are complete, press Create Test Chart, and save the files (you’ll get both SVG and PNG) in a convenient location.

Lens design programs — such as Code V let you process chart images, degrading them (adding blur, chromatic aberration, vignetting) using a realistic lens model. The chart images can be created with the Imatest Target Generator, which is a back-end for Test Charts, converting SVG charts to bitmap files. Charts for input to lens design programs must have gamma = 1 (linear gamma). When a lens design program has been used, the (blur) filter blocks won’t be needed, unless you need to simulate an anti-aliasing (optical lowpass) filter.

Images acquired from cameras — Raw or minimally-processed images,  converted to RGB with LibRaw or ReadRaw, work well. These include the actual images from development systems that need to be tuned. Blur and noise are already present in these images, so (blur) filter and noise blocks won’t be needed.

Most JPEG images from consumer cameras should be avoided because they are already heavily processed, including complex tonal response curves (with “shoulders”) and nonlinear and nonuniform bilateral filtering, making it difficult to obtain useful results.

Opening ISPsim

Press ISP Simulator in the the Utility dropdown menu or in the Utility tab on the right of the Imatest main window. This opens initial ISP Simulator window, which contains basic instructions and has many buttons grayed out (to minimize confusion). The instructions will be periodically updated. Before performing an analysis, you will need to

  • read in an image file, and
  • make sure you have the correct settings, which are saved from the previous run. You can update them if needed.

The order of pressing Read image file and ISP Settings is irrelevant.

ISPsim opening window. Click on image to view full-sized. The text will be updated.

Settings

The settings window lets you set up the analysis: you can select processing blocks, and adjust their parameters and the order of operations. To open the settings window, press the ISP Settings button on the upper-left of the ISP Simulator window. Since ISP settings are saved from the previous run, you won’t always need to open the settings window. Settings can be made before or after reading the image (but always before for batches of images).

The Settings window contains a large number of processing blocks. Some, like Sharpen or Bilateral Filter, have several associated parameters and are contained inside rectangular frames.  Others, like Exposure or Gain, which have at most one associated parameter, are not displayed inside frames. Their order is not related to the order of operations to be selected.

ISPsim settings screen

The Image Processing Blocks window,, on the right, contains the sequence of operations. Blank lines are ignored. They are intended to make it easy to insert, arrange, and delete entries, and are ignored when the settings are transferred to the main window).

Selecting and ordering image processing blocks

1. Choose a block to include in the image processing pipeline.
2. Adjust parameters — sliders, popup menus, or edit boxes.
3. Use the Set popup menu next to each block to enter the selected block into the Image Processing Blocks list box on the right. All the Set popups have the same contents: Set, 1, 2, 3, …, 20. Click on the Set popup, then click on the line number where you want the block to be entered. Choosing Set (instead of a line number) cancels the operation.
4. Since the block parameters are copied to the list box, you can reuse blocks by changing their settings and entering them on a different line.
5. The tint of the Set box indicates the status of the block.  White with a green background  indicates that the block has been selected and appears in the Image Processing Blocks list box.   White with a red background  indicates that the block has been adjusted, but not (yet) selected. Press Set then the line number to select it. Press Set then Set (not a line number) to reset the box to Black/white. In the above window, both the Add and Correct cos4 lens shading popups are  white/red  because they are both affected by the setting; they will be both reset to Black/White when one has been selected.
6. The Image Processing Blocks list box contains many blank lines. They are there to make it easy to add and edit lines, and they are ignored when the calculations are performed.
7. The order of the processing blocks can be conveniently edited using the buttons (Insert or Delete (line)Move (line_ up or down, etc.) below the Image Processing Blocks list box.
8. Pressing  OK  saves the settings and closes the Settings window. The selected image processing blocks (with blank lines removed) appear in the ISP Simulator window.
SUMMARY: Settings are made in two steps: (1) Adjust the parameter, and
(2) move it into the appropriate line in the Image Processing blocks box.
Since it’s easy to forget the second step, the Set window is changed to
 White with a red background 
 when the corresponding parameter has been adjusted.

For example, Filter 2 (on the left of the settings window) was copied to line 9 by selecting the Set dropdown on the left of the Filter 2 frame, then selecting 9 in the dropdown menu (which contains 1-20). In most cases, parameters are copied along with the lock name. Note that there is considerable space in the Settings window to add new blocks. Several are planned, and we are always interested in customer requests.

Image processing blocks

As we indicated, updating the calculations applies image processing blocks in the selected sequence. Depending on the input image source, some of the  degradation or enhancement steps may have been performed prior to entering the image into ISPsim. For example, JPEGs from consumer cameras typically have nonlinear, nonuniform bilateral filters (we don’t recommend them for ISPsim). Noise and filtering (blurring) have already been implicitly applied to images acquired from cameras (i.e., you don’t have to add noise and blur because they are present in the image).

Here is a list of the processing functions currently available (December 2024). Most are standard Matlab functions or custom Imatest code; the Lanman bilateral filter is a user-supplied function from the Mathworks File Exchange. Nonuniformity or nonlinearity are indicated in bold blue. Nonuniform or nonlinear operations are not recommended for image information metric calculations.

Processing block Description Function:
described in link
Input
gamma
Not actually a processing blockInput gamma is critically important for keeping track of the image gamma at each state of the processing. There will almost certainly be errors if it is entered incorrectly. Input gamma is typically 1 for (linear) raw images or around 0.45 (0.5 is close enough) for interchangeable color space images (sRGB, Adobe RGB, etc.) Gamma, Tonal Response Curves, and related concepts
Linearize (equivalent to Gamma target 1, which is recommended) Linearize the image (remove the gamma encoding). Images can be linearized, operations can be applied, then a final encoding gamma can be reapplied near the end of the ISP pipeline. Gamma = 1 is recommended for most processing blocks, such as standard sharpening (the 2D version of the 1D sharpening described on the Sharpening page. Not recommended for USM sharpening.  
Gamma Apply gamma encoding to an image. Gamma can be selected by a slider (shown above) and a popup menu that contains Target and Mult. Important because the input and output may be gamma-encoded (often with gamma ≅ 0.5), but many operations may need to be performed with gamma = 1. For Mult
imageout = imageinputγ. For Target, where the current value of gamma is γ_current ,
imageout = imageinput(γ/γ_current).
Gamma, Tonal Response Curves, and related concepts

Bayer mosaic

Demosaic

Demosaic converts a mosaiced Bayer raw file from an image sensor with a Bayer Color Filter Array (CFA) into a 3-color RGB file using the MATLAB demosaic function. Demosaicing is a complex process that can generate artifacts and affects the Noise Power Spectrum. Bayer raw files can also be demosaiced by the Imatest LibRaw and ReadRaw modules.

Bayer mosaic takes converts a 3-color RGB image into a monochrome, mosaiced pseudo-raw image that needs to be demosaiced to be converted back into an RGB image. It can be useful for studying the effects of demosaicing when ISPsim starts with simulated (RGB) images. It uses a simple, straightforward algorithm (with no artifacts) to convert RGB images into one of the four Bayer alignments: {RGGB, GRBG, GBRG, or BGGR}.

demosaic

Imatest raw processing

Exposure

Gain = 1/Exposure

Gain (set by slider)

Exposure/gain multiplier (gamma = 1 (linear) recommended)

Exposure (a multiplier usually < 1) is typically applied to simulated images before noise is added. It represents an actual change in exposure.

Gain = 1/Exposure is typically applied after noise has been added. Combining these two blocks is equivalent to dividing the Exposure Index (EI; commonly known as ISO speed) by Exposure. This decreases the Signal-to-Noise Ratio. For example, for a base EI of 100, applying Exposure = 0.25 before the noise and 1/Exposure = 4 after the noise is equivalent to increasing the EI to 400.

Gain (multiplier) can be applied at any point in the pipeline. 

 

Add, correct cos4 lens shading

Also called lens “vignetting” (gamma = 1 (linear) recommended)

Adding lens shading can be done for simulated images early in the ISP pipeline, before noise has been added. It doesn’t need to be added for real camera images.

Lens shading can be corrected later in the pipeline, while gamma is still 1.

 
Negative Invert the image, i.e., turn it into a negative. Infrequently used. Best performed on linear images (gamma = 1 (linear) recommended).  
Image degradations: blur and noise.  Often found in images acquired from cameras prior to processing. Operations are generally linear.
Fog (veiling glare)

Fog the image: equivalent to adding flare light or veiling glare.
imageout = fog + (1-fog)*imageinput   fog is Typically a small fraction, <0.2.

Negative values of fog can be used to correct for black level offset. 

 
Gaussian
Filter 1
Blur the image (before applying noise). This simulates lens blurring. imgaussfilt:  2-D Gaussian filtering of images with parameter sigma.
Noise n (Gaussian) Add noise to the image. Will be filtered by Gaussian Filter 2. imnoise:  Add noise to the HSV V channel. Parameters sigma [] and Luma noise [].
Gaussian Filter 2 Blur the image. Affects the noise spectrum if applied after noise. The spectrum for σ = 0.5 is similar to output of demosaicing (in raw conversion), which decreases noise from 1 to 0.5 at Nyquist. imgaussfilt:  2-D Gaussian filtering of images with parameter sigma.
Tonal enhancement:  Correct colors or apply one of three tone mapping algorithms, used for displaying High Dynamic Range (HDR) images. Tonal response may be highly nonlinear.
Color Correction Matrix (CCM) Apply a Color Correction Matrix (CCM), which can be calculated and saved in Color/Tone. using the processed image from ISPsim at the stage where the CCM is to be applied (usually near the end of the ISP pipeline). The Set CCM button to the right of the CCM checkbox opens a window (shown on the right; click on thumbnail to view full-sized) that lets you set up the matrix (read it from a file or paste it from the clipboard and select options (linearization, etc.)). Color Correction Matrix describes the CCM, which is calculated in Color/Tone.
Tone mapping

Render high dynamic range (HDR) image for viewing in displays with limited dynamic range. Tone mapping is a technique used to approximate the appearance of high dynamic range images on displays with a more limited dynamic range. Nonuniform and nonlinear

tonemap:  Render high dynamic range image for viewing
Local tone mapping Alternative tone mapping algorithm for HDR images using Laplacian filtering. Has a different set of adjustments. Produces different results (more saturated images). Nonuniform and nonlinear localtonemap 
Contrast-Limited Histogram Equalization CLAHE operates on small regions in the image, called tiles, rather than the entire image. Each tile’s contrast is enhanced, so that the histogram of the output region approximately matches the histogram specified by the ‘Distribution’ parameter. The neighboring tiles are then combined using bilinear interpolation to eliminate artificially induced boundaries. The contrast, especially in homogeneous areas, can be limited to avoid amplifying any noise that might be present in the image. Nonuniform and nonlinear adapthisteq:  Contrast-limited adaptive histogram equalization (CLAHE)
Spatial enhancement:  sharpening and/or noise reduction. Output depends on image content— may be highly nonlinear.
Sharpen USM (Unsharp Mask)

Sharpens the grayscale or RGB input image using the unsharp masking (USM) method. Most visible on edges. USM works by subtracting a gaussian blur function from the original image. If threshold > 0, low-contrast regions may not be sharpened. See Wikipedia.

This function is not linear. It caused some inconsistencies with the image information metrics. Designed to work directly on images, which should not be linearized. Nonlinear (a surprise; not indicated in MATLAB documentation)

imsharpen: Unsharp Masking (USM)
Sharpen
Standard

Sharpens the grayscale or RGB input image using a 2D version of the 1D sharpening method described in the Sharpening page. Most visible on edges. It works by subtracting an amplitude-reduced replica of the original image, arranged on a circular locus with radius R, from the original image. 

To maintain linearity, Linearize should be checked. This causes the image to be linearized (gamma-encoding removed) at the start of the calculations. Then sharpening is applied to the linearized image, then gamma encoding is reapplied. Recommended for testing the effects of sharpening on image information metrics, such as SNRi or Edge SNRi.

Because standard sharpening is not a MATLAB function, we include more explanation in the box below.

Custom Imatest function. 

Either USM or Standard sharpen can be applied (but not both).

Bilateral filter

Bilateral filtering was proposed by Tomasi and Manduchi in 1998 as a non-iterative method for edge-preserving smoothing.

    1. Half-width w is the half-size of the Gaussian bilateral filter window.
    2. sigma (range) is the spatial-domain standard deviation.
    3. sigma (domain) is the the intensity-domain standard deviation.

imbilatfilt (MATLAB)

bfilter2 (from the Mathworks File Exchange): 

 

A complete (though elementary) Image Processing pipeline can be simulated by reading a raw or minimally processed image (demosaiced by ReadRaw), then applying operations such as Color Correction Matrix (which also applies a gamma curve), sharpening, and a bilateral filter (a simple example— there are many options).

Sharpening (standard; not USM) is an Imatest (not a MATLAB) function, designed to maintain linearity.

As we mentioned above, this is a 2D version of the 1D sharpening method described in the Sharpening page. It was created when we were trying to determine if USM, which is implemented with the MATLAB imfilter function, is nonlinear (it is). It is also closer to typical camera sharpening than USM, which is more computationally intensive.

For sharpening radius R and amount A, define ksharp = A/(A+1). The filter kernel is a 2R+1×2R+1 matrix H (units of pixels), calculated by (1) setting each entry at a distance r from the center to H(r) = max(|R-r|,0), (2) setting H = H/∑H, then setting the entry at the center, H(R+1,R+1) = 1.

For a filter with Radius = 2, Amount = 3 (strongly sharpened), the 5×5 kernel is

-0.0092 -0.0409 -0.0535 -0.0409 -0.0092
-0.0409 -0.0222  0      -0.0222 -0.0409
-0.0535  0       1.0000  0      -0.0535
-0.0409 -0.0222  0      -0.0222 -0.0409
-0.0092 -0.0409 -0.0535 -0.0409 -0.0092

Standard sharping should be used with Linearize γ for gamma-encoded images. It is a linear operation (as long as excessive sharpening doesn’t saturate the image). 

 

Running ISPsim

Read an input image file if it hasn’t been read in already. It doesn’t have to be a test chart; any pictorial image can be used. The sequence of reading an image file and updating the settings doesn’t matter. Most types of image can be used, though as we indicated above, we don’t recommend highly processed JPEGs from consumer cameras.  

Batches of files  If several files are selected, they will be read, processed, and automatically saved in a batch using the stored settings. (Most outputs won’t be displayed, but of course you can open the saved files for examination.) The dialog box shown on the right will open after you select the files. Files named root_file_name.ext will be saved as root_file_nameext-ispsim.png.

Before running a batch of images you should run a single image to be sure the settings are correct. Note that the batch calculations are not optimized for speed, so batch processing, which typically takes several seconds per image, is not suited for high volumes of images.

Process the image using Update calculations or another of of the buttons in the Calculation group (light blue box) on the lower-left of the ISP simulator window. The processed image appears. Alternatively, you can press Read image file (2) to read a file with the same scene content but different image processing to compare with the first image.

Processed image in ISPsim

Calculations can be updated by pressing buttons in the Calculate group, on the left.

Update calculations Starting with the input image, process each block shown in the listbox on the upper-left. Display the results when processing is complete.
Input Restore the input image view.
Display results for 1s during updates (checkbox) Display the results for 1 second after each block when running Update calculations.
Step through calculations Step through the calculations manually, pushing the button for each block. Cumulative results are displayed after each block.
Step & show single block Step through the calculations manually, pushing the button for each block. Results for the current block-only (not the cumulative results) are displayed after each block.

The side-by-side view is particularly valuable. 

 

Next, either

  • Read another file, which should have the same scene content but different image processing from the first image. This is done by pressing Read image file (2). Examples include two images captured at different ISO speeds, two images saved with as different file types (e.g, different levels of JPEG compression), or an in-camera JPEG and an externally-converted JPEG).
  • Process the image by selecting settings in the left column, then pressing Update calculations. Blocks that are checked in the left column are performed in top-to-bottom order.

When either of these operations has been performed all the buttons are enabled. You can quickly toggle between the original and processed image, display measurements comparing the two, or save the processed image. When you are ready you can run another set of image processing operations, starting from either the original image or the processed image.

Here is the Image Processing display for an image of a Spilled Coins chart (cropped). The input image (of good quality, but with some visible noise) is displayed.

image_processing_spilled_coins_inputImage processing window showing Spilled Coins input image
Zoomed in (for display-only)

Cropping and zooming— There are two distinct types of crop/zoom operation: zooming for display-only and cropping for calculations (as well as display).

  • Zooming (cropping for display-only) is performed by the standard Matlab procedures: clicking on the image (to zoom in), dragging and clicking to select a region, or by double-clicking (to zoom out). These does not affect calculations such as MTF.
  • Cropping for calculations as well as display is performed by pressing the Crop button in the Analysis and View area below the image. This brings up the standard Imatest coarse and fine crop windows. This approach affects calculations such as the MTF curve (which is image-dependent for several processing blocks) or the mean SSIM calculation (though the detailed SSIM plot is unaffected). Pressing the Crop button enables the Zoom out and Zoom to crop buttons on the lower-right of the window. To remove the crop, press the Crop button and select the entire image.

Utilities

Several utilities are available in the dropdown menus at the top of the image processing window. (There is little room for added buttons in the window.)

File Display and/or Save screen Display the screen in an image viewer (Irfanview recommended) and optionally save it. This function is in several interactive modules.
  Save image Save the processed image. Normally images will be saved in full precision (except if 8-bit max (below) is checked).
  Save pseudo-raw/remosaiced image Save the image in a pseudo-raw (remosaiced) or special format, including Bayer, RCCC, or specific channel can be selected. Many options. See Synthetic RAW images.
  Save image as monochrome Save the image (which may be color) as a monochrome image.
  Swap Endian (16, 32-bit input) Swap the order of bytes within pixels (useful in rare instances where they are incorrect)
  Save image files with 8-bit max precision Unchecked (off) by default. If set, images will be saved in 8-bit precision. (This should normally be unchecked).
  Save image as HDR Save the image in HDR (High Dynamic Range) format
View Colorbar (grayscale or color) Grayscale or color: Used in SSIM and PSNR displays. The colors in the color bar can be changed in Options II.
  Crop Lets you select a crop for image analysis operations (MTF, SSIM, etc.) Same as the Crop button in the Analysis and View area.
Analysis Most functions duplicate buttons in the Analysis and View section, but there are several additions.
  Image Statistics Call the Image Statistics module for viewing image statistics such as histograms and cross-section profiles.
  Radial Geometry Call the Radial Geometry module, which can return an image with added or corrected optical distortion, lateral chromatic aberration, and/or rotation.
  OCR Optical Character Recognition using Matlab’s OCR function
  Detect faces Uses the Matlab CAMShift routine, described below.
  Detect people Uses the Matlab detectPeopleACF routine, described below. Less effective than Face detection.
Help Open web pages with descriptions of various image processing blocks.

Results display and analysis

The display is controlled by buttons below the image or by the Analysis dropdown menu. You can choose between a visual display of the Input or Processed image or a calculated display (an analysis comparing the input and processed images).

Results display summary: Selected by buttons below the image or Analysis dropdown menu
Input Display the input image (1)
Processed Display the processed image (2)
MTF Display the MTF of the processed / input image as a function of spatial frequency. Sensitive to cropping.
MTFnn Display a polar plot of MTF70-MTF10 (spatial frequencies where MTF is nn% of low frequency value)
MTFnnP Display a polar plot of MTF70P-MTF10P (spatial frequencies where MTF is nn% of peak value)
SSIM Display the Structural Similarity Index, which is discussed in detail on the page for the SSIM module. Better correlated to visual differences (degradations) than PSNR.
PSNR & DIff Display the Peak Signal-to-Noise Ratio and the difference between images.
OCR Optical Character Recognition results using Matlab’s OCR function
Detect faces Face detection results using the Matlab CAMShift routine.
Detect people People detection results using the Matlab detectPeopleACF routine, described below. Less effective than Face detection.

 

image_processing_displays

The View input button on the left, just below the image, toggles between View input (when the processed image is selected) and View processed (when the input image is selected). This enables rapid visual comparison of the two images. The zoom setting is preserved when you switch images. The View input/processed button performs the same functions as the Input and Processed buttons in the Analysis and View area. The other buttons in this area display calculated results.

SSIM displays the Structural Similarity Index, which is discussed in detail on the page for the SSIM module. It’s primary use is in measuring the visible effects (i.e., degradation) of image compression from saving files (for example, JPEGs of varying quality) and from data transmission.

MTF (Modulation Transfer Function) calculates the transfer function between the Processed and Input images using a 2D Fourier transform similar to the calculation in the Random module, but with one important difference. Unlike the Random module, where the scaled Power Spectral Density in gray areas to the left and right of the active area (the random/Spilled Coins/Dead Leaves pattern) is subtracted from the total power spectral density of the active area to remove most of the noise, there is no noise reduction. Hence this MTF measurement is extremely sensitive to noise.

image_processing_MTF_noisyMTF for noisy Gaussian-filtered image after Unsharp Masking

The high frequency rolloff is the effect of Gaussian filter 2, which is applied after the noise has been added (and hence shapes the spectral power of the noise).

You can see the MTF for Unsharp Mask (USM)-only (in this case with Radius = 1.5 and Amount = 2.5) by unchecking Noise (gaussian) and Gaussian filter 2 in the Image Processing area to the left of the image, then pressing Update calculations. Unsharp Masking has a different spectral response from the type of sharpening described in the Sharpening page: It’s response is not cyclical. It rises to an asymptotic level of Amount+1 and stays high.

This is a good example of how Image Processing can be used to explore the effects of processing blocks on both appearance and measurements.

image_processing_MTF_USMMTF for USM (Unsharp Mask: Radius = 1.5; Amount = 2.5)

Side-by-side view

The side-by-side view allows you to compare the input and processed images side-by-side, i.e., right next to each other. Click the Side-by-side view checkbox just below View input or View processed (on the left, below the image). When the box is first checked the two images are displayed in their entirety. If you crop one, the other will have the identical crop. This makes for meaningful comparisons.

image_processing_side_by_sideSide-by-side view of Dead Leaves chart. Noise, Bilateral filter, and USM added on the right.

When Side-by-side view is enabled, the Analysis and view section on the bottom (which contains MTF, SSIM, etc.) is disabled. Uncheck to re-enable it.

Remosaicing (undemosaicing)

By clicking FileSave pseudo-raw (undemosaiced) image (after a file has been read), you can save the image in a synthetic Bayer RAW format as well as one of several other formats. The output can be a standard image file format or pure binary. A dialog box opens that allows a number of options.

Mosaicing or channel selection  None (Normal color file output), Remosaic (Bayer format), RCCC (Red-Clear-Clear-Clear): R bright, RCCC (Red-Clear-Clear-Clear): R = C/3, Monochrome (Y = luminance), Monochrome (mean: equal weights), Red, Green, Blue. For remosaicing (creating Bayer RAW files), Remosaic (Bayer format) would be selected.

Red in RmCn  lets you select one of the four Bayer configurations.

Gamma adjust  lets you adjust the gamma of the output curve. Keep it at 1 for no change. Use 2 (or 2.2) to go from a typical color space gamma to linear (gamma = 1).

Save file format  lets you select a standard image file format (PNG, JPG (90% quality), TIF (large), BMP, Binary 8-bit, or Binary 16-bit. The binary files can be read into Generalized Read Raw.

Green channel emphasis  lets you emphasize the green channel so that the synthetic RAW image resembles actual raw images, which typically are strongest in green. Several Blue/Red levels are available.

When you select Save, a dialog box lets you select the location and file name. The default is root_file_name_png (with the selected extension).

Optical Character Recognition (OCR)

OCR has been added in Imatest 5.0, using Matlab’s OCR function, which is an implementation of Tesseract-OCR. To use it,

  • Read an image containing text of interest.
  • Process the image if required. Processing can consist of image degradations (such as blur, noise, etc.) to see how they affect detection or image enhancements (unsharp mask, bilateral filtering, etc.) to see if detection can be improved.
  • Crop the image to the text region (strongly recommended if significant areas contain features other than text), then
  • Click OCR.

This opens the OCR window and performs a text recognition operation on the crop of the image. Results for the sample image on the right (mildly degraded with Noise (gaussian) = 0.002; Gaussian filter 2 = 0.7) are shown below. You can download this image and experiment with to see how various degradations and enhancements affect OCR performance.

Be forewarned. Matlab’s OCR performance is not impressive. Text that appears to be quite readable does not do well, especially for font sizes under 12 points. Performance is comparable to several free or low-cost OCR programs such as gImageReader (a GUI front-end for Tesseract-ocr) and TopOCR.

 

Sample image: Click for a
full-sized version that can be downloaded.

The left side sample image consists a set of characters (QWERTYUIOPASDFGHJKLZXCVBNM1234567890) of different sizes ranging from 20 to 7 points in normal, bold, and negative bold Calibri font. These are characters used in automotive license plates. The file (here) was created in Microsoft Word. The remainder of the image is a portion of the Enhanced eSFR ISO chart, with wedges and two high contrast squares. These can be used to correlate MTF measurements with OCR performance.

OCR window, showing results for mildly-degraded crop of the sample image

OCR Settings

Character Subset  Results can be improved by entering a character subset to limit the valid output characters (all characters are allowed if Character Subset is blank), then pressing CALCULATE OCR. For the sample image, the subset consists of Latin capital letters and numbers (typical of automobile license places). It makes only a small improvement.

QWERTYUIOPASDFGHJKLZXCVBNM1234567890

Standard OCR does not work very well with license plates. Several license plate detection routines are available in the Matlab File Exchange. We may add one or two if they work well and the license allows.

Display  Text (shown) is the default. You can also select Confidence & words, which shows the Word Confidence and individual word. Here are a few lines from the display.

0.8545   QWERTYUIOPASDFGHJKLZXCVBNM1234567890
0.8361   QWERTYUIOPASDFGHJKLZXCVBNM123456789O
0.9018   18
0.7842   QWERTVU|OPASDF6HJKLZX(VBNM1234567890
0.8339   16
0.7468   QWEKTYUIOPASDFGHJKLZXCVBNM1234567B90
0.8254   14
0.7252   QWERYYUIOPASDFGI-1JKLZX(\/ENM1Z34567E9(!
0.7784   12
0.5777   QWERTYUWDDASDFGHJI(LZXCVBNM113A567E9u
0.6549   11
0.6276   uwEuHu\onAsur:.r<n<.zxn’aNM:23-4ss7s9u
0.7658   m

Copy to clipboard  You can copy the current display into the clipboard for use in text editors or other applications.

Save results  saves the current display.

Variable or fixed width font can be selected in the Settings dropdown menu.

Face and People detection

Face and people detection can be called from the Analysis dropdown menu. Both currently use the Matlab default settings. (We may add an options window in the future.) See

Face Detection and Tracking Using CAMShift  and  detectPeopleACF

Face detection works somewhat better than people detection. Here is an example, using an image shamelessly stolen from http://epaperpress.com/portfolio/columbia.html. The soggy author of Imatest is on the left. Click Update Calculations to remove the annotations (to reset the image).

Example of Face Detection (Imatest author on the left)

Face detection works pretty well much of the time, but seriously… How can you miss Paul and John?