Backtransformation
- ultrasound_processing.transform_back.transform_back(frame, depth, alpha, offset_frame, offset=0, resolution=0.01)[source]
Transforms back the masked image to the original coordinate system. This is the main function that calls the other functions to perform the interpolation.
- Parameters:
frame (np.ndarray) – The input frame.
depth (float) – Depth of the frustum.
thetas (Tuple[float, float]) – The range of theta values.
alpha (float) – Half angle of the ultrasound device in radians.
offset (float) – Offset value between the top of the frame and the US source.
offset_frame (float) – Offset value for the frame.
resolution (float) – Resolution value for upscaling or downscaling.
- Returns:
Interpolated frame.
- Return type:
np.ndarray
- ultrasound_processing.transform_back.generate_cartesian_volume(depth, thetas, offset, resolution)[source]
Creates a Cartesian grid and corresponding spherical coordinates within a conic frustum.
- Returns:
Tuple containing the image shape, filtered R, THETA arrays and valid indices.
- ultrasound_processing.transform_back.transform_spherical_to_cartesian(R: ndarray, THETA: ndarray)[source]
Converts spherical coordinates (R, THETA) to Cartesian (X, Z).
- Parameters:
R (np.ndarray) – Radial distances.
THETA (np.ndarray) – Polar angles.
- Returns:
X and Z Cartesian coordinates.
- Return type:
Tuple[np.ndarray, np.ndarray]
- ultrasound_processing.transform_back.transform_cartesian_to_spherical(X: ndarray, Z: ndarray)[source]
Converts Cartesian coordinates (X, Z) to spherical coordinates (R, THETA).
- Parameters:
X (np.ndarray) – X coordinates.
Z (np.ndarray) – Z coordinates.
- Returns:
Radial distances R and polar angles THETA.
- Return type:
Tuple[np.ndarray, np.ndarray]
- ultrasound_processing.transform_back.find_nearest_indices(image_R, image_THETA, frame_R, frame_THETA)[source]
Finds the nearest neighbor indices and interpolation weights.
- ultrasound_processing.transform_back.bilinear_interpolation(frame: ndarray, indices, weights, shape, cone_mask_indices)[source]
Performs bilinear interpolation on the image.
- Parameters:
frame (np.ndarray) – The input frame.
indices (tuple) – Index arrays for R and THETA.
weights (tuple) – Weight arrays.
shape (tuple) – Shape of the output image.
cone_mask_indices (tuple) – Indices for valid cone region.
- Returns:
Interpolated image.
- Return type:
np.ndarray