pmace¶
pmace.pmace¶
pmace.utils¶
pmace.nrmse¶
Functions:
|
Compute Normalized Root-Mean-Square-Error (NRMSE) between two images. |
|
Calculate the phase error between complex images. |
|
Perform phase normalization on reconstructed image. |
- pmace.nrmse.compute_nrmse(input_img, ref_img, cstr=None)[source]¶
Compute Normalized Root-Mean-Square-Error (NRMSE) between two images.
This function calculates the NRMSE between the provided image and reference image.
- Parameters:
input_img (numpy.ndarray) – Complex-valued image for comparison.
ref_img (numpy.ndarray) – Reference image for comparison.
cstr (numpy.ndarray, optional) – Area for comparison. If provided, only this region will be considered.
- Returns:
float – The computed NRMSE between two images.
- pmace.nrmse.pha_err(img, ref_img)[source]¶
Calculate the phase error between complex images.
The phase error is determined as the minimum of | angle(img) - angle(ref_img) - 2*k*pi| where k belongs to {-1, 0, 1}.
- Parameters:
img (numpy.ndarray) – Complex-valued image for comparison.
ref_img (numpy.ndarray) – Reference image for comparison.
- Returns:
numpy.ndarray – Phase error between two images.
- pmace.nrmse.phase_norm(img, ref_img, cstr=None)[source]¶
Perform phase normalization on reconstructed image.
Since reconstruction is blind to the absolute phase of the ground truth image, this function applies a phase shift to the reconstruction results given the known ground truth image.
- Parameters:
img (numpy.ndarray) – The reconstruction that needs phase normalization.
ref_img (numpy.ndarray) – The known ground truth image or reference image.
cstr (numpy.ndarray, optional) – Preconditioning window. If provided, only this region will be considered.
- Returns:
numpy.ndarray – The phase-normalized reconstruction as a complex image (dtype: np.complex64).
pmace.display¶
Functions:
|
Plot scan points. |
|
Plot the NRMSE (Normalized Root Mean Squared Error) versus the number of iterations. |
|
Plot complex object images and error images compared with a reference image. |
- pmace.display.plot_scan_pt(scan_pt, save_dir)[source]¶
Plot scan points.
- Parameters:
scan_pt (numpy.ndarray) – Array of scan points as (x, y) coordinates.
save_dir (str) – Directory to save the plot.
- pmace.display.plot_nrmse(nrmse_ls, title, label, abscissa=None, step_sz=15, fig_sz=[10, 4.8], display=False, save_fname=None)[source]¶
Plot the NRMSE (Normalized Root Mean Squared Error) versus the number of iterations.
- Parameters:
nrmse_ls (list or array) – List of NRMSE values for each iteration or a dictionary of labels and NRMSE values.
title (str) – Title for the plot.
label (list) – List containing the X and Y axis labels and the label for the legend (e.g., [‘X Label’, ‘Y Label’, ‘Legend Label’]).
abscissa (list or None) – X-axis values corresponding to NRMSE data. If None, it is automatically generated.
step_sz (int) – Step size for X-axis ticks.
fig_sz (list) – Size of the figure in inches (width, height).
display (bool) – Display the plot if True.
save_fname (str or None) – Save the plot to a file with the specified filename (without extension).
- pmace.display.plot_cmplx_img(cmplx_img, img_title='img', ref_img=None, display_win=None, display=False, save_fname=None, fig_sz=[8, 3], mag_vmax=1, mag_vmin=0, phase_vmax=3.141592653589793, phase_vmin=-3.141592653589793, real_vmax=1, real_vmin=0, imag_vmax=0, imag_vmin=-1)[source]¶
Plot complex object images and error images compared with a reference image.
- Parameters:
cmplx_img (numpy.ndarray) – Complex-valued image.
img_title (str) – Title for the complex image.
ref_img (numpy.ndarray or None) – Reference image. If provided, error images will be displayed.
display_win (numpy.ndarray or None) – Pre-defined window for displaying images.
display (bool) – Display images if True.
save_fname (str or None) – Save images to the specified file directory.
fig_sz (list) – Size of image plots in inches (width, height).
mag_vmax (float) – Maximum value for showing image magnitude.
mag_vmin (float) – Minimum value for showing image magnitude.
phase_vmax (float) – Maximum value for showing image phase.
phase_vmin (float) – Minimum value for showing image phase.
real_vmax (float) – Maximum value for showing the real part of the image.
real_vmin (float) – Minimum value for showing the real part of the image.
imag_vmax (float) – Maximum value for showing the imaginary part of the image.
imag_vmin (float) – Minimum value for showing the imaginary part of the image.