ptyrad.utils.image_proc#
Image processing tools for fitting, cropping, normalization, etc.
Functions
|
Center crops a 2D or 3D array (e.g., an image). |
|
|
|
|
|
|
|
Estimate the center, radius, and std of a CBED pattern by minimizing the difference between the observed image and a synthetic model. |
|
|
|
Utility function that returns an estimate of the radius of rbf from CBED |
|
Create a 2D Gaussian-blurred circular mask. |
|
|
|
|
|
- ptyrad.utils.image_proc.guess_radius_of_bright_field_disk(image, thresh=0.5)[source]#
Utility function that returns an estimate of the radius of rbf from CBED
- Parameters:
image (ndarray)
thresh (float)
- ptyrad.utils.image_proc.fit_cbed_pattern(image, initial_guess=None)[source]#
Estimate the center, radius, and std of a CBED pattern by minimizing the difference between the observed image and a synthetic model.
- Parameters:
image (np.ndarray) – The input image to fit.
initial_guess (dict, optional) – Dictionary with initial guess parameters.
- Returns:
Dictionary containing the fitted parameters as dict[‘center’, ‘radius’, ‘std’].
- Return type:
dict
- ptyrad.utils.image_proc.make_gaussian_mask(Npix, radius, std, center=None)[source]#
Create a 2D Gaussian-blurred circular mask.
- Parameters:
Npix (int) – Size of the square mask (Npix x Npix).
radius (float) – Radius of the circular mask.
std (float) – Standard deviation of the Gaussian blur.
center (tuple) – (y, x) coordinates of the center of the circle.
- Returns:
A 2D Gaussian-blurred circular mask.
- Return type:
np.ndarray
- ptyrad.utils.image_proc.center_crop(image, crop_height, crop_width, offset=(0, 0))[source]#
Center crops a 2D or 3D array (e.g., an image).
- Parameters:
image (numpy.ndarray) – The input array to crop. Can be 2D (H, W) or 3D (H, W, C).
crop_height (int) – The desired height of the crop.
crop_width (int) – The desired width of the crop.
- Returns:
The cropped image.
- Return type:
numpy.ndarray