paint.preprocessing.focal_spot_extractor
Classes
Private initializer to ensure objects are only created using |
Functions
|
Get the specific marker coordinates based on the target. |
|
Convert (x, y) coordinates to an aimpoint in the target image based on marker positions. |
|
Calculate the center of intensity (x, y) coordinates in a 2D flux image. |
|
Detect a focal spot within an image using UTIS focal spot segmentation. |
|
Center a 2D flux image based on its intensity center of mass. |
Module Contents
- class paint.preprocessing.focal_spot_extractor.FocalSpot
Private initializer to ensure objects are only created using
from_flux()orload().Initializes attributes with default placeholder values.
- flux: torch.Tensor
- aim_point_image: tuple[float, float] = (0.0, 0.0)
- aim_point: torch.Tensor
- classmethod from_flux(flux: torch.Tensor, aim_point_image: tuple[float, float], aim_point: torch.Tensor) FocalSpot
Create a
FocalSpotobject from provided data.Parameters
- fluxtorch.Tensor
Intensity image of the detected focal spot.
- aim_point_imagetuple[float, float]
Detected center of intensity in image coordinates (height, width).
- aim_pointtorch.Tensor
Detected center of intensity in global coordinates (E, N, U).
Returns
- FocalSpot
Initialized
FocalSpotobject.
- paint.preprocessing.focal_spot_extractor.get_marker_coordinates(target: str | int) tuple[torch.Tensor, Ellipsis]
Get the specific marker coordinates based on the target.
Parameters
- targetstr | int
Target ID used to determine which marker coordinates should be used.
Returns
- tuple[torch.Tensor, …]
Coordinates for the markers from the considered target.
- paint.preprocessing.focal_spot_extractor.convert_xy_to_enu(aim_point_image: tuple[float, float], target: str | int) torch.Tensor
Convert (x, y) coordinates to an aimpoint in the target image based on marker positions.
Parameters
- aim_point_imagetuple[float, float]
Relative aim point coordinates (x, y).
- targetstr | int
The target object containing marker information.
Returns
- torch.Tensor
Aimpoint coordinates in the target image.
- paint.preprocessing.focal_spot_extractor.compute_center_of_intensity(flux: torch.Tensor, threshold: float = 0.0) tuple[float, float]
Calculate the center of intensity (x, y) coordinates in a 2D flux image.
Parameters
- fluxtorch.Tensor
A 2D tensor representing the flux/intensity image.
- thresholdfloat, optional
Minimum intensity value for pixels to be included in the calculation (Default: 0.0).
Returns
- float
x coordinate of the center of intensity.
- float
y coordinate of the center of intensity.
- paint.preprocessing.focal_spot_extractor.detect_focal_spot(image: torch.Tensor, target: str | int, utis_model: torch.nn.Module) FocalSpot
Detect a focal spot within an image using UTIS focal spot segmentation.
Parameters
- imagetorch.Tensor
Cropped image containing the focal spot to be detected, with the shape (height, width).
- targetstr | int
Target center and dimensions used for aimpoint calculation.
- utis_modeltorch.nn.Module
UTIS model checkpoint used to compute the flux.
Returns
- FocalSpot
Detected focal spot with flux, image coordinates, and global aimpoint.
- paint.preprocessing.focal_spot_extractor.center_flux_image(flux: torch.Tensor, target_id: str | int, length: float = 6.0, n_grid: int = 256) torch.Tensor
Center a 2D flux image based on its intensity center of mass.
Parameters
- fluxtorch.Tensor
2D tensor with shape [H, W] representing the flux distribution on the target surface.
- target_idstr | int
Target identifier that determines scaling parameters.
- lengthfloat
Physical edge length of the cropped flux image.
- n_gridint
Resolution of the output centered image.
Returns
- torch.Tensor
Centered flux image with shape [n_grid, n_grid].