medpy.graphcut.energy_label.boundary_difference_of_means#
- medpy.graphcut.energy_label.boundary_difference_of_means(graph, label_image, original_image)[source]#
Boundary term based on the difference of means between adjacent image regions.
An implementation of the boundary term, suitable to be used with the
graph_from_labels
function.This simple energy function computes the mean values for all regions. The weights of the edges are then determined by the difference in mean values.
The graph weights generated have to be strictly positive and preferably in the interval \((0, 1]\). To ensure this, the maximum possible difference in mean values is computed as:
\[\alpha = \|\max \bar{I} - \min \bar{I}\|\], where \(\min \bar{I}\) constitutes the lowest mean intensity value of all regions in the image, while \(\max \bar{I}\) constitutes the highest mean intensity value With this value the weights between a region \(x\) and its neighbour \(y\) can be computed:
\[w(x,y) = \max \left( 1 - \frac{\|\bar{I}_x - \bar{I}_y\|}{\alpha}, \epsilon \right)\]where \(\epsilon\) is the smallest floating point step and thus \(w(x,y) \in (0, 1]\) holds true.
- Parameters:
- graphGCGraph
The graph to add the weights to.
- label_imagendarray
The label image.
- original_imagendarray
The original image.
Notes
This function requires the original image to be passed along. That means that
graph_from_labels
has to be called withboundary_term_args
set to the original image.This function is tested on 2D and 3D images and theoretically works for all dimensionalities.