viqa.nr_metrics.qmeasure.QMeasure¶
- class viqa.nr_metrics.qmeasure.QMeasure(data_range=255, normalize=False, **kwargs)[source]¶
Class to calculate the Q-Measure [1] for an image.
- score_val¶
Q-Measure value of the last calculation.
- Type:
float
- parameters¶
Dictionary containing the parameters for QMeasure calculation.
- Type:
dict
- Parameters:
data_range ({1, 255, 65535}, default=255) – Data range of the returned data in data loading. Is used for image loading when
normalize
is True. Passed toviqa.utils.load_data()
.normalize (bool, default False) – If True, the input images are normalized to the
data_range
argument.**kwargs (optional) – Additional parameters for data loading. The keyword arguments are passed to
viqa.utils.load_data()
.chromatic (bool, default False) –
If True, the input images are expected to be RGB images.
Note
Currently not supported.
Notes
This metric will always be calculated with
float32
precision.References
- score(img, **kwargs)[source]¶
Calculate the Q-Measure between two images.
- Parameters:
img (np.ndarray or Tensor or str or os.PathLike) – Image to calculate score of.
**kwargs (optional) – Additional parameters for Q-Measure calculation. The keyword arguments are passed to
viqa.nr_metrics.qmeasure_utils.qmeasurecalc.qmeasure()
.hist_bins (int, default=128) – Number of bins for the histogram calculation.
num_peaks (int, default=2) – Number of peaks to consider in the histogram.
- Raises:
ValueError – If the input image is not a 3D volume.
- Warns:
RuntimeWarning – If the input image is a 2D RGB image. Q-Measure is only defined for 3D volumes.
- Returns:
score_val – Q-Measure value.
- Return type:
float
- print_score(decimals=2)[source]¶
Print the Q-Measure value of the last calculation.
- Parameters:
decimals (int, default=2) – Number of decimal places to print the score value.
- Warns:
RuntimeWarning – If
score_val
is not available.
- export_results(path, filename)¶
Export the score to a csv file.
- Parameters:
path (str) – The path where the csv file should be saved.
filename (str) – The name of the csv file.
Notes
The arguments get passed to
viqa.utils.export_results()
.
- load_images(img)¶
Load the image.
Uses the
viqa.utils.load_data()
function to load the image.- Parameters:
img (np.ndarray, viqa.ImageArray, torch.Tensor, str or os.PathLike) – The image to load.
- Returns:
img – The loaded image as an
viqa.utils.ImageArray
.- Return type:
viqa.ImageArray