Document
ISO Flowchart of e-SFR measurement algorithm

Diagram depicting the key steps of the e-SFR algorithm


Read in images
Lens shading correction
解决由于lens的光学特性,由于镜头对于光学折射不均匀导致的镜头周围出现阴影的情况。
Code
matlab
python
Split raw image into 4 sub-channels
Bayer
R, Gr (Green Row), B, Gb (Green Balance)
Undemosaiced
In this document, we sometimes refer to RAW files from commercial cameras or development systems as Camera RAW to distinguish them from Bayer RAW files, which are standard monochrome image files that contain undemosaiced (Bayer) data.
Camera RAW≠Bayer RAW
Undemosaiced~=4 channels
Code
matlab
python
Calculate fixed sizes for the chart
Code (Load config)
matlab
python
Threshold image and find regions
Code
matlab
python
Find the coordinate of centroids
Calculate the SFR
for square; square_names=[c, r, t, l, ......]; (for each square)
for patch; patch_name=[t, b, r, l]; (for each ROI)
for chan; channels(for each colour channel)
Code (Get the scope of the ROI)
matlab
python
- The "Threshold image and find regions" have already found the ideal coordinate of each square.
- The real square coordinate has the minimum distance between the ideal one and itself.
Sketch map of finding the ROI (named as patch & sub_patch in MATLAB codes)
- t
- b
- l
- r
sfrmat3
matlab
dat = computed sfr data
oename optional name of oecf LUT file containing 3xn or 1xn array. The camera optoelectronic conversion function (OECF). 伽马校正部分用于校正非线性光输出(与之对应的是显示器的信号输入)。光输入强度和电信号输出强度之间的关系称为相机光电转换函数(OECF),为图像捕获设备提供伽马校正曲线形状。
Size or Shape of "a" (img_patch)
matlab
python
rotatev2
Code
matlab
python
If the difference between 2 rows > 2 columns: rotate to vertical
Edge contrast
tleft, tright, test
Loop for each color

The first estimate of edge slope & offset
Code
matlab
python
deriv1 (Compute derivative)? (27 May 2020 updated to use 'same' conv option)
matlab
python
Apply convolution for each row of the image matrix.
The "derivative" it calculated is quite likely! Whereas, I don't handle how to calculate the derivative of a discrete sequence!
centroid (Compute centroid for derivative array for each line in ROI)
matlab
python
Different from ISO document.


Each row (r) of the edge spread image is an estimate of the camera edge spread function (ESF). Each of these ESFs is differentiated to form its discrete line spread function (LSF). The position of the centroid (C) of each r LSF is determined along the continuous variable x, where x has the range (1, X) [see Formula (D.3)].
It really works! If you don't believe it, use x=[3, 2, 3] to make a test.
Though it is in operation, I have no idea about the weird algorithm.
The final estimate of edge slope and offset
Code
matlab
python
findedge 线性拟合(Done in the first estimate)
matlab
- slope从高次幂开始
- cent=slope(1)*index + slope(2)
- place(n) =fitme(color,1)*n + fitme(color,2)
python
- slope从高次幂开始
- cent=slope[0]*index + slope[1]
- place(n) =fitme[color,0]*n + fitme[color,1]
x = fitme(color, 1) y + fitme(color, 2) % so the slope is the inverse of the one that you may expect
hamming: place= mid = midpoint (maximum) of the window function
If mid = (n+1)/2 then the usual symmetric Hamming
centroid (Mentioned above)
根据centroid线性拟合;根据线性拟合再计算centroid;根据线性的centroid再计算slope
Edge slope judgment
Code
matlab
python
Correction (Derivative correction)
Code (fir2fix)
matlab
python
fir2fix
matlab
python

D ( k) is the correction for the frequency response of the discrete derivative used to derive the point spread function from the edge spread function,
Project (shift the image data along the edge direction to the edge of the ROI)
Code
matlab
python
project 到线性拟合的方向上
Projects the data in array bb along the direction defined by Used by sfrmat11 and sfrmat2 functions. Data is accumulated in 'bins' that have a width pixel.
Compute the one-dimensional derivative of the edge-spread function
Code
matlab
python
Shift to center the line spread function (LSF) vector
Code
matlab
python
cent: shift of one-dimensional array, so that is located at .
是横坐标的中心,centroid 也返回横坐标,但与纵坐标数值有关
Apply a Hamming window to the LSF vector
Code
matlab
python
Compute the discrete Fourier transform (DFT) of the windowed, binned LSF vector; Compute the modulus of the complex DFT array
matlab
python
Normalize the modulus vector by the zero-frequency value (first element of the array) to obtain the E-SFR
matlab
python
Correct the E-SFR for the discrete derivative response
Code
matlab
python
Report E-SFR result
Code
matlab
python
Derived metrics
Construct the square_results matrix from patch_results
matlab
python
根据特殊算出的采样频率 freq 作为样本点(横坐标),对 mtf 值(对应值)进行插值,在查询
Screenshots of MATLAB & Python


- patch_result: each color channel
Condense and assess patch results
matlab
python
Each SFR data of a color channel is equal to the mean of t, b, r, l
Calculate tilt and falloff
tilt
matlab
python
Screenshots of Python & MATLAB

- for outer_name: outer 的 05Data h & v,列拼接
- for outer_name: 对行求 mean,形成 outer_data
- for outer_name: outer_data 取 Gr 和 Gb 行,行拼接
- 求列 mean
- ;
falloff
matlab
python
- fetch 05Data Gr & Gb from center
- calculate the mean
- falloff = center_data - mean(outer_data);