pythonimage-processingscikit-imagessim

ValueError: win_size exceeds image extent. If the input is a multichannel (color) image, set multichannel=True


I am trying to calculate SSIM value for two images but I am getting error.

when i try to find SSIM value ssim_ = compare_ssim(img_np, out.detach().cpu().numpy()[0]) i am having error ValueError: win_size exceeds image extent. If the input is a multichannel (color) image, set multichannel=True.

I have tried


Solution

  • The shape (1, 256, 256) is interpreted as an image with 1 row, 256 columns and 256 color channels.

    You may use numpy.squeeze for removing the redundant dimension:

    img_np = np.squeeze(img_np)
    

    The new shape is going to be (256, 256) - shape of a valid Grayscale image.


    Most Python packages assumes "Channels-Last" image format.
    See: A Gentle Introduction to Channels-First and Channels-Last Image Formats.