Skip to content

QiuJueqin/CDP-Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contrast Detection Probability Calculator

This repository provides:

  • A toolbox for calculating contrast detection probability (CDP) of an imaging system

  • A simulated imaging system for generating HDR images given scene luminance map, and alternatively

  • A utility for annotating and extracting RoIs from CDP test patterns in Image Engineering® DTS device

What is CDP?

中文介绍:谈谈 CDP (Contrast Detection Probability)

Contrast detection probability (CDP) is a metric to describe the performance of an imaging system to reproduce contrasts in the physical scenes. Since a distinguishable contrast in an image is a prerequisite for modern computer vision algorithms, CDP can be regarded as a core functionality to measure the CV-oriented image quality of an imaging system.

More detailed introduction and use cases about CDP can be found in [1], [2], and [3].

Basic idea

By its theoretical definition, CDP is the ratio of the area under a contrast-to-pdf (probability distribution function) curve, constrained by an upper and a lower bounds (, where is the target contrast and is a confidence interval), to the whole area under this pdf curve (see figure below). In a discrete digital imaging system, however, we can only obtain this ratio by dividing the number of observations withing the bounds by the number of all observations.

CDP definition in [2]

Inspired by Image Engineering® DTS-Evaluation software, our toolbox calculates CDP based on an RoI-to-RoI manner (see figure below), i.e., given two flatten patches with known contrast and luminance levels (in cd/m2), the CDP is calculated by counting the number of pixel-pairs from two image RoIs that are able to reproduce that contrast value, then dividing by the number of all possible pixel-pairs.

We calculate CDP based on an RoI-to-RoI manner. The figure is copied from [5], and more appropriately, the y-label should be "the normalized frequency"

For example, given two neutral patches in the physical world with luminance 100cd/m2 and 300cd/m2 respectively, their contrast is following the Michelson contrast definition. Suppose we use a camera to capture this scene, and get an output image with two 10*10 square RoIs corresponding to these two patches, then the CDP can be obtained by counting the ratio of all pixel-pairs that reproduce the target contrast (based on pixel values), to the total 1002=10,000 pixel-pairs.

A CDP value is a function of the target contrast value, the target luminance level (by averaging the luminance of two patches), and, of course, the characteristic of the imaging system. So if camera A produces a higher CDP values then camera B, we can say that camera A has higher probability to distinguish the objects with a certain degree of difference, and at a certain luminance level, in their real use scenarios.

Usage

Demo

A comprehensive demo was provided, simply by running

python demo.py

and annotating the CDP charts following the instructions, you will get results on the ./simulation/simulated_images directory.

CDP Calculator

The CDPCalculator class now supports two calculating modes: user-specified target contrast(s) mode and all target contrasts mode:

  • The user-specified target contrast(s) mode is run by calling calculate() method. Given a set of patches with known luminance levels and an interesting target contrast value (or several contrast values), this method will search from all patch-pairs and find those that satisfy this target contrast value(s). The CDP values will be calculated for all these patch-pairs. See figure below.

CDPs with respect to different luminance levels. Here four target contrasts (6%, 10%, 20%, and 30%) are evaluated. Two regions with CDP drops in the middle can be clearly observed because there exists SNR drop during HDR blending. The right side drop is caused by the response saturation

  • The all target contrasts mode is run by calling calculate_all() method. In this mode the CDP values will be calculated for all possible patch-pairs. See figures below.

CDPs with respect to different target contrasts and luminance levels

Same as above figure, in top view

See the documents in the cdp_calculator.py for more info about its usage.

Simulated Imaging System & DTS RoIs Extractor

If you do not own a DTS device, this toolbox provides a simulated CDP pattern generator and a simulated imaging system to help generate synthetic images. See figure below.

Synthetic HDR image of CDP pattern generated by capture_hdr()

A convenient utility is also provided for users to annotate and extract RoIs from real or synthetic CDP images. See figures below.

RoIs extractor

Extracted RoIs

Reference

1. Detection Probabilities: Performance Prediction for Sensors of Autonomous Vehicles. Geese M, Seger U, and Paolillo A (2018)

2. Contrast Detection Probability - Implementation and Use Cases. Artmann U, Geese M, Gäde M (2019)

3. Imatest Documentation: Contrast Detection Probability. https://www.imatest.com/docs/cdp/

4. ISO 12232:2019 Photography — Digital still cameras — Determination of exposure index, ISO speed ratings, standard output sensitivity, and recommended exposure index

5. Comparison of Detectability Index and Contrast Detection Probability. Robin B. Jenkin (2019)

6. Implementierung von CDP: Entwicklung eines Programmiercodes in Python zur Untersuchung und Messung von CDP bei Fahrerassistenzkameras. Lukas Ebbert (2018)

License

Copyright 2020 Qiu Jueqin

Licensed under MIT.

About

Contrast Detection Probability Calculator

Resources

Stars

Watchers

Forks

Languages