nanopyx.methods.squirrel.error_map

 1import numpy as np
 2from ...core.transform.error_map import ErrorMap
 3
 4
 5def calculate_error_map(img_ref: np.ndarray, img_sr: np.ndarray):
 6    """
 7    Calculate the error map between a reference image and a super-resolved image.
 8
 9    This function utilizes the ErrorMap class to compute the error map between
10    the provided reference image (`img_ref`) and the super-resolved image (`img_sr`).
11    It optimizes the parameters to minimize the difference between the scaled,
12    blurred version of the super-resolved image and the reference image, and
13    returns the resulting error map, the root square error (RSE), and the
14    root square Pearson correlation (RSP).
15
16    Parameters
17    ----------
18    img_ref : np.ndarray
19        The reference image against which the super-resolved image is compared.
20        Expected to be a 2D numpy array.
21    img_sr : np.ndarray
22        The super-resolved image that is being evaluated.
23        Expected to be a 2D numpy array.
24
25    Returns
26    -------
27    tuple
28        A tuple containing the following elements:
29        - np.ndarray: The error map as a 2D numpy array of type np.float32.
30        - float: The root square error (RSE) value.
31        - float: The root square Pearson correlation (RSP) value.
32    """
33
34    emc = ErrorMap()
35    emc.optimise(img_ref, img_sr)
36    return np.asarray(emc.imRSE, dtype=np.float32), emc.getRSE(), emc.getRSP()
def calculate_error_map(img_ref: numpy.ndarray, img_sr: numpy.ndarray):
 6def calculate_error_map(img_ref: np.ndarray, img_sr: np.ndarray):
 7    """
 8    Calculate the error map between a reference image and a super-resolved image.
 9
10    This function utilizes the ErrorMap class to compute the error map between
11    the provided reference image (`img_ref`) and the super-resolved image (`img_sr`).
12    It optimizes the parameters to minimize the difference between the scaled,
13    blurred version of the super-resolved image and the reference image, and
14    returns the resulting error map, the root square error (RSE), and the
15    root square Pearson correlation (RSP).
16
17    Parameters
18    ----------
19    img_ref : np.ndarray
20        The reference image against which the super-resolved image is compared.
21        Expected to be a 2D numpy array.
22    img_sr : np.ndarray
23        The super-resolved image that is being evaluated.
24        Expected to be a 2D numpy array.
25
26    Returns
27    -------
28    tuple
29        A tuple containing the following elements:
30        - np.ndarray: The error map as a 2D numpy array of type np.float32.
31        - float: The root square error (RSE) value.
32        - float: The root square Pearson correlation (RSP) value.
33    """
34
35    emc = ErrorMap()
36    emc.optimise(img_ref, img_sr)
37    return np.asarray(emc.imRSE, dtype=np.float32), emc.getRSE(), emc.getRSP()

Calculate the error map between a reference image and a super-resolved image.

This function utilizes the ErrorMap class to compute the error map between the provided reference image (img_ref) and the super-resolved image (img_sr). It optimizes the parameters to minimize the difference between the scaled, blurred version of the super-resolved image and the reference image, and returns the resulting error map, the root square error (RSE), and the root square Pearson correlation (RSP).

Parameters

img_ref : np.ndarray The reference image against which the super-resolved image is compared. Expected to be a 2D numpy array. img_sr : np.ndarray The super-resolved image that is being evaluated. Expected to be a 2D numpy array.

Returns

tuple A tuple containing the following elements: - np.ndarray: The error map as a 2D numpy array of type np.float32. - float: The root square error (RSE) value. - float: The root square Pearson correlation (RSP) value.