ants.math.image_similarity
- image_similarity(fixed_image, moving_image, metric_type='MeanSquares', fixed_mask=None, moving_mask=None, sampling_strategy='regular', sampling_percentage=1.0)[source]
Measure similarity between two images. NOTE: Similarity is actually returned as distance (i.e. dissimilarity) per ITK/ANTs convention. E.g. using Correlation metric, the similarity of an image with itself returns -1.
ANTsR function: imageSimilarity
- Parameters:
fixed (
ants.core.ANTsImage) – the fixed imagemoving (
ants.core.ANTsImage) – the moving imagemetric_type (
str) –- image metric to calculate
MeanSquares Correlation ANTSNeighborhoodCorrelation MattesMutualInformation JointHistogramMutualInformation Demons
fixed_mask (
ANTsImage (optional)) – mask for the fixed imagemoving_mask (
ANTsImage (optional)) – mask for the moving imagesampling_strategy (
string (optional)) –- sampling strategy, default is full sampling
None (Full sampling) random regular
sampling_percentage (
scalar) – percentage of data to sample when calculating metric Must be between 0 and 1
- Return type:
scalar
Example
>>> import ants >>> x = ants.image_read(ants.get_ants_data('r16')) >>> y = ants.image_read(ants.get_ants_data('r30')) >>> metric = ants.image_similarity(x,y,metric_type='MeanSquares')