...
...
Formulas for the Diagnostics Noise Measurement dialog
Introduction
This document details the calculations performed by the Sensor Control – Diagnostics – Noise Measurement GUI in DevWare/DevWareX.
...
The Noise Measurement calculations are performed on the region of interest (ROI) defined by the Rectangle Mouse Selection. Note that row and column indexes in DevWare start from zero. The raw data will be separated by color plane, and the ROI defined on the GUI will be projected into each plane. The ROI may be adjusted slightly if needed so that it is aligned to the color filter array (CFA) pattern.
For Bayer data, or any other 2×2 CFA there will be four planes, and the ROI will be the same size in each plane. For the RGB-IR 4×4 CFA there will be five planes, and the red and blue planes in the ROI will have exactly half as many pixels as the green and IR planes.
Definitions
For the following definitions the data has I rows, J columns and K frames. Each color channel is analyzed individually. Variances in the time domain are using the unbiased estimation; K – 1 in the denominator. Noise is the square root of this variance.
1. Indexes and pixel values:
row number i∈1…I
column number j∈1…J
frame number k∈1…K
pixel value Pi,j,k
2. Mean signal value of each pixel: μ(i,j)=1Kk=1KPi,j,k
3. Mean signal value of each row: μrow=1Jj=1Jμ(i,j)
4. Mean signal value of each column: μcol(j)=1Ii=1Iμ(i,j)
5. Mean signal value of each row of each frame: μrow(i,k)=1Jj=1JP(i,j,k)
6. Mean signal value of each column of each frame: μcol(j,k)=1Ii=1IP(i,j,k)
7. Mean signal value of all pixels local to a row: μrow_local=110u=i-5i+4μrow(u)
8. Mean signal value of all pixels local to a column: μcol_local(j)=110v=j-5j+4μcol(v)
9. Mean signal value of all pixels: μ=1I×Ji=1Ij=1Jμ(i,j)
10. Variance of each pixel: σ2(i,j)=1K-1k=1KPi,j,k-μ(i,j)2
11. Variance of each row: σrow_temp2=1K-1k=1Kμrowi,k-μrow(i)2
12. Variance of each column: σcol_temp2(j)=1K-1k=1Kμcolj,k-μcol(j)2
13. Mean variance of all pixels: σtot_temp2=1I×Ji=1Ij=1Jσ2(i,j)
14. Mean variance of all rows:
σrow_temp2=1Ii=1Iσrow_temp2
15. Mean variance of all columns:
σcol_temp2=1Jj=1Jσcol_temp2(j)
Noise Measurement Results
The noise measurement results are formatted as tab-separated text data. There is a row of data for each color plane. The columns are as follows:
Signal: The average pixel value of the entire data set. The black level is subtracted.
Signal=μ
RMS_Dyn: Temporal noise of all pixels. This includes pixel-wise, row-wise and column-wise dynamic noise, but not fixed pattern noise.
RMSDyn=σtot_temp
Pix_Dyn: Isolate the pixel-wise temporal noise by removing the row-wise and column-wise noise.
PIXDyn=σtot_temp2-σrow_temp2-σcol_temp2
FPN: All fixed pattern noise, including row-wise and column-wise.
FPN=1I×Ji=1Ij=1J[μi,j-μ]2
Col_FPN: Column-wise fixed pattern noise only.
ColFPN=1Jj=1Jμcolj-μ2
ColLFPN: Also column-wise fixed pattern noise, but using only nearby columns for the reference signal level so that uneven illumination or lens shading does not get included as false noise level.
Collocal_FPN=1Jj=1Jμcolj-μcol_localj2
Row_FPN: Row-wise fixed pattern noise only.
RowFPN=1Ii=1Iμrowi-μ2
RowLFPN: Also row-wise fixed pattern noise, but using only nearby rows for the reference signal level so that uneven illumination or lens shading does not get included as false noise level.
Rowlocal_FPN=1Ii=1Iμrowi-μrow_locali2
Col_Dyn: Column-wise temporal noise.
ColDyn=σcol_temp
Row_Dyn: Row-wise temporal noise.
RowDyn=σrow_temp
Total: Combine all temporal noise and all fixed pattern noise to get total noise.
total=σtot_temp2+FPN2
Signal to noise ratios (SNR) in dB are also calculated for each of the above noise values.
SNRnoise=20log10μnoise
The EMVA 1288 SNR is calculated as the linear ratio of mean signal over total noise.
SNREMVA1288=μtotal
Algorithms in DevWare
DevWare uses a 'single-pass' algorithm for calculating variances in the time domain. This means that it doesn't need to store the frames, so any number of frames can be sampled and the amount of memory needed for the calculations is only proportional to the size of the ROI. However the algorithms are mathematically equivalent to the above formulas.
See: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
Scripting Noise Measurement
The function of the Noise Measurement dialog can be scripted with DevWare Python. The ROI can be set with apbase.set_mouse_selection, and the other parameters can be set with apbase.setstate. Below is a minimal example Python code to do a noise measurement on raw data. The ROI is set to a 100x100 square in the center of the image. The results are printed to the Python Console window:
[Basic Noise Measurement]
import threading
import time
def measure():
x1 = apbase.Camera().sensor.width // 2
y1 = apbase.Camera().sensor.height // 2
apbase.set_mouse_selection('rectangle', x1-50, y1-50, x1+49, y1+49)
apbase.setstate("Noise Image Type", 0)
apbase.setstate("Noise Frames", 50)
apbase.setstate("Noise Defects", 0)
apbase.setstate("Delay Noise Measurement", 0)
apbase.setstate("Begin Noise Measurement", 1)
while apbase.getstate("Begin Noise Measurement") > 0:
time.sleep(1)
results = apbase.getstate('Noise Measurement Results')
print(results)
threading.Thread(target=measure).start()
The "Noise Image Type" parameter chooses between analyzing the raw data from the camera, or the processed RGB data output of the DevWare colorpipe. The possible values are: 0 = raw data as it came from the camera; 2 = RGB data after processing by the DevWare colorpipe; 3 = both raw and processed data.
The while loop has to run in a background thread because DevWare suspends processing images while scripts are running in the main thread.
...
2017 October 17
...
Bill Dirks
...
First draft.
...
...
...
...
...
...
...
...
...
The document describes how to define the ROI, lists the detailed formulas, and gives an example of how to script noise measurements.