medpy.metric.binary.ravd#
- medpy.metric.binary.ravd(result, reference)[source]#
Relative absolute volume difference.
Compute the relative absolute volume difference between the (joined) binary objects in the two images.
- Parameters:
- resultarray_like
Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else.
- referencearray_like
Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else.
- Returns:
- ravdfloat
The relative absolute volume difference between the object(s) in
result
and the object(s) inreference
. This is a percentage value in the range \([-1.0, +inf]\) for which a \(0\) denotes an ideal score.
- Raises:
- RuntimeError
If the reference object is empty.
Notes
This is not a real metric, as it is directed. Negative values denote a smaller and positive values a larger volume than the reference. This implementation does not check, whether the two supplied arrays are of the same size.
Examples
Considering the following inputs
>>> import numpy >>> arr1 = numpy.asarray([[0,1,0],[1,1,1],[0,1,0]]) >>> arr1 array([[0, 1, 0], [1, 1, 1], [0, 1, 0]]) >>> arr2 = numpy.asarray([[0,1,0],[1,0,1],[0,1,0]]) >>> arr2 array([[0, 1, 0], [1, 0, 1], [0, 1, 0]])
comparing arr1 to arr2 we get
>>> ravd(arr1, arr2) -0.2
and reversing the inputs the directivness of the metric becomes evident
>>> ravd(arr2, arr1) 0.25
It is important to keep in mind that a perfect score of 0 does not mean that the binary objects fit exactely, as only the volumes are compared:
>>> arr1 = numpy.asarray([1,0,0]) >>> arr2 = numpy.asarray([0,0,1]) >>> ravd(arr1, arr2) 0.0