medpy.graphcut.energy_voxel.boundary_difference_power#
- medpy.graphcut.energy_voxel.boundary_difference_power(graph, xxx_todo_changeme8)[source]#
Boundary term processing adjacent voxels difference value using a power relationship.
An implementation of a boundary term, suitable to be used with the
graph_from_voxels
function.Finds all edges between all neighbours of the image and uses their difference in intensity values as edge weight.
The weights are normalized using an power function and a smoothing factor \(\sigma\). The \(\sigma\) value has to be supplied manually, since its ideal settings differ greatly from application to application.
The weights between two neighbouring voxels \((p, q)\) is then computed as
\[w(p,q) = \frac{1}{1 + |I_p - I_q|}^\sigma\], 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.
- sigmafloat
The sigma parameter to use in the boundary term.
- 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.