Module i2pp.core.interpolate_element_data
Interpolate image data to FEM-Elements.
Functions
def interpolate_image_to_discretization(dis: Discretization,
image_data: ImageData,
interpolation: Interpolation) ‑> list[Element]-
Expand source code
def interpolate_image_to_discretization( dis: Discretization, image_data: ImageData, interpolation: Interpolation, ) -> list[Element]: """Performs interpolation of image data onto the FEM Discretization. This function uses the settings provided in the `interpolation` object to control the interpolation process. The pixel values are assigned to the FEM elements using one of the following approaches: - "nodes": Computes the mean pixel value for each element based on its node values. - "allvoxels": Computes the mean pixel value for each element based on all voxels inside it. - "elementcenter": Assigns pixel values based on the center of each element. Arguments: dis: The Discretization object containing FEM surfaces, elements and node coordinates. image_data: A structured representation containing 3D pixel data, grid coordinates, orientation, and metadata. interpolation: The interpolation configuration object, containing settings like the interpolation method, outlier filtering, and surface value assignments. Returns: A list of FEM elements with interpolated pixel data. """ enum_interpolation_method = InterpolationType(interpolation.method) interpolator = enum_interpolation_method.create_interpolator( filter_outliers=interpolation.filter_outliers, set_node_value=interpolation.set_node_value, idw_power=interpolation.idw_power, ) elements = interpolator.compute_element_data(dis, image_data) # apply fixed value to elements at boundary if configured if interpolation.set_ele_value is not None: _set_surf_element_value(dis, elements, interpolation.set_ele_value) return elementsPerforms interpolation of image data onto the FEM Discretization.
This function uses the settings provided in the
interpolationobject to control the interpolation process. The pixel values are assigned to the FEM elements using one of the following approaches:- "nodes": Computes the mean pixel value for each element based on its node values.
- "allvoxels": Computes the mean pixel value for each element based on all voxels inside it.
- "elementcenter": Assigns pixel values based on the center of each element.
Arguments
dis: The Discretization object containing FEM surfaces, elements and node coordinates. image_data: A structured representation containing 3D pixel data, grid coordinates, orientation, and metadata. interpolation: The interpolation configuration object, containing settings like the interpolation method, outlier filtering, and surface value assignments.
Returns
A list of FEM elements with interpolated pixel data.