rehanguha / brisque

Blind/Referenceless Image Spatial QUality Evaluator (BRISQUE)
https://pypi.org/project/brisque/
Apache License 2.0
55 stars 8 forks source link

Fixed an issue with alpha channel in PNGs #3

Closed ajakka closed 2 years ago

ajakka commented 2 years ago

Hello, I've been using your library lately and noticed that it doesn't play well with the alpha channel in PNG images, It produces this error:

"/usr/local/lib/python3.9/site-packages/brisque/brisque.py", line 34, in score
    gray_image = skimage.color.rgb2gray(image)
  File "/usr/local/lib/python3.9/site-packages/skimage/_shared/utils.py", line 394, in fixed_func
    return func(*args, **kwargs)
  File 
"/usr/local/lib/python3.9/site-packages/skimage/color/colorconv.py", line 875, in rgb2gray
    rgb = _prepare_colorarray(rgb)
  File 
"/usr/local/lib/python3.9/site-packages/skimage/color/colorconv.py", line 140, in _prepare_colorarray
    raise ValueError(msg)
ValueError: the input array must have size 3 along `channel_axis`, got (3200, 1440, 4)

I made it so the code removes that alpha channel before proceeding to the next steps.

Thank you.

rehanguha commented 2 years ago

Hi, Thanks... This makes sense. Did you test the code with and without alpha channel image?

ajakka commented 2 years ago

Yes, I tested it with both JPEGs and PNGs and results look accurate, but If you could test as well, that would be appreciated.

rehanguha commented 2 years ago

I have a bit tough schedule now... Will merge this now and if issues come up then will revert or edit it as necessary.