Skimage documentation includes a "var" parameter, but when I try to use it noise_image = random_noise(image, mode=chosen_noise_mode, var=0.1)
I got the following error:
var keyword not in allowed keywords []
The error seems to make sense but it's on the documentation so i'm a bit confused. Can anyone help ?
reproducible example:
from skimage.util import random_noise
image = cv2.imread("my_image.jpg", flags=cv2.IMREAD_UNCHANGED)
# as skimage and cv2 have different encoding formats:
image = img_as_float(image)
noise_types=["pepper","poisson","speckle"]
chosen_noise_mode=noise_types[random.randint(0,2)]
noise_image = random_noise(image, mode=chosen_noise_mode, var=0.1, mean = 0)
If you want pass any/both of var
then or mean
your mode must be 'gaussian'
random_noise(image, mode='gaussian', var=0.1)
or
# because mode is gaussian by default
random_noise(image, var=0.1)
if mode is not 'gaussian'
then don't pass any of var and mean
random_noise(image, mode=mode)
Refrence: source code