-
-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
Describe the bug
I tried to get a score for a gray-scale image, but I got the following error,
ValueError: the input array must have size 3 along channel_axis, got (336, 164)
Desktop (please complete the following information):
- OS: [Ubuntu]
- Version [20.04]
Additional context
import imquality.brisque as brisque
import PIL.Image
path = '/home/image.png'
img = PIL.Image.open(path)
brisque.score(img)
ValueError Traceback (most recent call last)
Input In [11], in <cell line: 6>()
4 path = '/home/maser/Projects/Wood_Project/Dataset/Heidelberg_Spectrometer/UV_VIS/Scan0_r0_l0_163,57516.png'
5 img = PIL.Image.open(path)
----> 6 brisque.score(img)
File ~/anaconda3/envs/quality/lib/python3.9/site-packages/imquality/brisque.py:160, in score(image, kernel_size, sigma)
159 def score(image: PIL.Image.Image, kernel_size=7, sigma=7 / 6) -> float:
--> 160 scaled_features = calculate_features(image, kernel_size, sigma)
161 return predict(scaled_features)
File ~/anaconda3/envs/quality/lib/python3.9/site-packages/imquality/brisque.py:130, in calculate_features(image, kernel_size, sigma)
129 def calculate_features(image: PIL.Image, kernel_size, sigma) -> numpy.ndarray:
--> 130 brisque = Brisque(image, kernel_size=kernel_size, sigma=sigma)
131 # WARNING: The algorithm is very sensitive to rescale
132 # FIXME: this is empirically the best configuration; however, scikit-image warns about bi-quadratic implementation.
133 # Fix this warning error in version of scikit-image 0.16.0.
134 with warnings.catch_warnings():
File ~/anaconda3/envs/quality/lib/python3.9/site-packages/imquality/brisque.py:45, in Brisque.__init__(self, image, kernel_size, sigma)
38 def __init__(
39 self,
40 image: typing.Union[PIL.Image.Image, numpy.ndarray],
41 kernel_size: int = 7,
42 sigma: float = 7 / 6,
43 ):
44 self.image = pil2ndarray(image)
---> 45 self.image = skimage.color.rgb2gray(self.image)
46 self.kernel_size = kernel_size
47 self.sigma = sigma
File ~/anaconda3/envs/quality/lib/python3.9/site-packages/skimage/_shared/utils.py:394, in channel_as_last_axis.__call__.<locals>.fixed_func(*args, **kwargs)
391 channel_axis = kwargs.get('channel_axis', None)
393 if channel_axis is None:
--> 394 return func(*args, **kwargs)
396 # TODO: convert scalars to a tuple in anticipation of eventually
397 # supporting a tuple of channel axes. Right now, only an
398 # integer or a single-element tuple is supported, though.
399 if np.isscalar(channel_axis):
File ~/anaconda3/envs/quality/lib/python3.9/site-packages/skimage/color/colorconv.py:875, in rgb2gray(rgb, channel_axis)
834 @channel_as_last_axis(multichannel_output=False)
835 def rgb2gray(rgb, *, channel_axis=-1):
836 """Compute luminance of an RGB image.
837
838 Parameters
(...)
873 >>> img_gray = rgb2gray(img)
874 """
--> 875 rgb = _prepare_colorarray(rgb)
876 coeffs = np.array([0.2125, 0.7154, 0.0721], dtype=rgb.dtype)
877 return rgb @ coeffs
File ~/anaconda3/envs/quality/lib/python3.9/site-packages/skimage/color/colorconv.py:140, in _prepare_colorarray(arr, force_copy, channel_axis)
137 if arr.shape[channel_axis] != 3:
138 msg = (f'the input array must have size 3 along `channel_axis`, '
139 f'got {arr.shape}')
--> 140 raise ValueError(msg)
142 float_dtype = _supported_float_type(arr.dtype)
143 if float_dtype == np.float32:
ValueError: the input array must have size 3 along `channel_axis`, got (336, 164)
zeyuanchen23, hosford42 and Priyadrasta-2111CS10
Metadata
Metadata
Assignees
Labels
No labels