Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

errors In scikit-image metrics on 1D array

I am trying to explore different skimage metrics on 1D array . I have two array noisy signal and clean signal. Code snippet is given below .

import numpy as np 
import skimage.metrics as M
clean_signal = np.arange(1,10, .1)
noisy_signal = clean_signal+np.random.normal(0,1,90)
M.mean_squared_error(noisy_signal, clean_signal)
M.peak_signal_noise_ratio(noisy_signal, clean_signal)
M.variation_of_information(noisy_signal, clean_signal)

Metrics which are given in code snippet are giving following errors .
For adapted_rand_error and variation_of_information I get Error

TypeError: 'numpy.float64' object cannot be interpreted as an integer 

and for peak_signal_noise_ratio I get error

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ValueError: image_true has intensity values outside the range expected for its data type. Please manually specify the data_range.

I would like to know how to fix these errors.

Thanks in advance

>Solution :

From the documentation, the function skimage.metrics.variation_of_information only accepts integer images:

skimage.metrics.variation_of_information(image0=None, image1=None, *, table=None, ignore_labels=())
(…)
Parameters:
image0, image1
ndarray of int Label images / segmentations, must have same shape.

The same is true for adapted_rand_error

For your other function, the error message is already telling you much. If we check the documentation again, you can see that the call signature is

skimage.metrics.peak_signal_noise_ratio(image_true, image_test, *, data_range=None)

You are supposed to specify the data_range parameter, in your case (min(noisy_signal ),max(noisy_signal )) should do

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading