medpy.graphcut.energy_label.boundary_stawiaski#
- medpy.graphcut.energy_label.boundary_stawiaski(graph, label_image, gradient_image)[source]#
Boundary term based on the sum of border voxel pairs differences.
An implementation of the boundary term in [1], suitable to be used with the
graph_from_labels
function.Determines for each two supplied regions the voxels forming their border assuming \(ndim*2\)-connectedness (e.g. \(3*2=6\) for 3D). From the gradient magnitude values of each end-point voxel the border-voxel pairs, the highest one is selected and passed to a strictly positive and decreasing function \(g(x)\), which is defined as:
\[g(x) = \left(\frac{1}{1+|x|}\right)^k\],where \(k=2\). The final weight \(w_{i,j}\) between two regions \(r_i\) and \(r_j\) is then determined by the sum of all these neighbour values:
\[w_{i,j} = \sum_{e_{m,n}\in F_{(r_i,r_j)}}g(\max(|I(m)|,|I(n)|))\], where \(F_{(r_i,r_j)}\) is the set of border voxel-pairs \(e_{m,n}\) between the regions \(r_i\) and \(r_j\) and \(|I(p)|\) the absolute of the gradient magnitude at the voxel \(p\)
This boundary_function works as an edge indicator in the original image. In simpler words the weight (and therefore the energy) is obtained by summing the local contrast along the boundaries between two regions.
- Parameters:
- graphGCGraph
The graph to add the weights to.
- label_imagendarray
The label image. Must contain consecutively labelled regions starting from index 1.
- gradient_imagendarray
The gradient image.
Notes
This function requires the gradient magnitude image of the original image to be passed along. That means that
graph_from_labels
has to be called withboundary_term_args
set to the gradient image. This can be obtained e.g. with generic_gradient_magnitude and prewitt fromscipy.ndimage
.This function is tested on 2D and 3D images and theoretically works for all dimensionalities.
References
[1]Stawiaski J., Decenciere E., Bidlaut F. “Interactive Liver Tumor Segmentation Using Graph-cuts and watershed” MICCAI 2008 participation