Оценка изображения в BRISQUE выдает ошибку

Нашел туториал, как оценивать изображение при помощи Brisque

import numpy as np
from skimage import io, img_as_float
import imquality.brisque as brisque

img = img_as_float(io.imread('2.jpeg', as_gray=True))
score = brisque.score(img)
print("Brisque score = ", score)

Но выдает ошибку

raise ValueError(msg)
ValueError: the input array must have size 3 along `channel_axis`, got (297, 275)

Google не помог,

image = cv2.imread(image_name)[:,:,:3]
img = rgb2gray(image)

def read_transparent_png(filename):
    image_4channel = cv2.imread(filename, cv2.IMREAD_UNCHANGED)
    alpha_channel = image_4channel[:,:,3]
    rgb_channels = image_4channel[:,:,:3]

    # White Background Image
    white_background_image = np.ones_like(rgb_channels, dtype=np.uint8) * 255

    # Alpha factor
    alpha_factor = alpha_channel[:,:,np.newaxis].astype(np.float32) / 255.0
    alpha_factor = np.concatenate((alpha_factor,alpha_factor,alpha_factor), axis=2)

    # Transparent Image Rendered on White Background
    base = rgb_channels.astype(np.float32) * alpha_factor
    white = white_background_image.astype(np.float32) * (1 - alpha_factor)
    final_image = base + white

это тоже не помогло.

img = img_as_float(io.imread('2.jpeg', as_gray=True))
if img.shape[-1] == 3:
    img2 = skimage.color.rgb2gray(img)
    score = brisque.score(img2)
    print("Brisque score = ", score)

В таком раскладе- ошибок нет, но и вывод пустой

Такой вариант еще пробовал img = (io.imread('2.jpeg', as_gray=True))[:,:,:3] IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed Как переконвертировать изображение, чтобы оно читалось?


Ответы (0 шт):