medpy.graphcut.energy_voxel.boundary_difference_linear#
- medpy.graphcut.energy_voxel.boundary_difference_linear(graph, xxx_todo_changeme2)[source]#
Boundary term processing adjacent voxels difference value using a linear relationship.
An implementation of a regional term, suitable to be used with the
graph_from_voxels
function.Finds all edges between all neighbours of the image and uses their normalized difference in intensity values as edge weight.
The weights are linearly normalized using the maximum possible intensity difference of the image. Formally, this value is computed as:
\[\sigma = |max I - \min I|\], where \(\min I\) constitutes the lowest intensity value in the image, while \(\max I\) constitutes the highest.
The weights between two neighbouring voxels \((p, q)\) is then computed as:
\[w(p,q) = 1 - \frac{|I_p - I_q|}{\sigma} + \epsilon\], where \(\epsilon\) is a infinitively small number and for which \(w(p, q) \in (0, 1]\) holds true.
When the created edge weights should be weighted according to the slice distance, provide the list of slice thicknesses via the
spacing
parameter. Then all weights computed for the corresponding direction are divided by the respective slice thickness. Set this parameter to False for equally weighted edges.- Parameters:
- graphGCGraph
The graph to add the weights to.
- original_imagendarray
The original image.
- spacingsequence of float or False
A sequence containing the slice spacing used for weighting the computed neighbourhood weight value for different dimensions. If False, no distance based weighting of the graph edges is performed.
Notes
This function requires the original image to be passed along. That means that
graph_from_voxels
has to be called withboundary_term_args
set to the original image.