pysdic.znssd_correction_exact#

znssd_correction_exact(result_1, result_2, groups, *, scale=1.0)[source]#

Normalize the gray levels of both views (ZNSSD) with the statistics of their groups, with the exact derivative. For a point \(i\) of the group \(G\) (statistics over \(n\) finite points) and \(z = (g - m) / s\) (statistics of \(G\), also for the points \(j\) of overlapping groups):

\[\frac{\partial g'_i}{\partial g_j} = \frac{\text{scale}}{s} \left( \delta_{ij} - \frac{1 + z_i z_j}{n} \right) \quad (j \in G)\]

The corrected Jacobians are derivative @ [J_1; J_2] where \(J_k\) are the raw Jacobians of the gray levels of the view \(k\) (rows in Fortran order of \((N_p, C)\): row \(p + c N_p\)).

Note

The exact derivative has \(\sum_G |G|^2\) entries per channel: a global group (neighborhood=None) gives a dense matrix, limited to small numbers of points.

Parameters:
Returns:

  • result_1 (pysdic.ImageProjectionResult) – The first projection with corrected gray levels, without Jacobians.

  • result_2 (pysdic.ImageProjectionResult) – The second projection with corrected gray levels, without Jacobians.

  • derivative (scipy.sparse.csr_matrix) – The derivative of the corrected gray levels of both views with respect to the raw ones, of shape \((2 N_p C, 2 N_p C)\): rows and columns \([0, N_p C)\) for the first view, \([N_p C, 2 N_p C)\) for the second one. Block diagonal for ZNSSD.

Return type:

Tuple[ImageProjectionResult, ImageProjectionResult, csr_matrix]