Opencv_contrib: cv.quality.QualitySSIM_compute(mat2,mat1) return only one chanel for rgb image in python language

Created on 30 Apr 2019  Â·  5Comments  Â·  Source: opencv/opencv_contrib

System information (version)
  • OpenCV => 4.1
  • Operating System / Platform => macos 10.12.6
  • Compiler => pip install opencv-contrib-python
Detailed description

my code is like this

import cv2 as cv

im1 = "/Users/admin/09.temp_src/476d375d4bd3980.jpg";
im2 = "/Users/admin/work/l75d4bda68432523980.jpg";

mat1 = cv.imread(im1)
mat2 = cv.imread(im2)

print("shape of image1: (%s,%s,%s)" % mat1.shape)
print("shape of image2: (%s,%s,%s)" % mat2.shape)

ssim_scalar ,map= cv.quality.QualitySSIM_compute(mat2,mat1)
print("ssim of per channel:")
print(ssim_scalar)

the images are rgb image with 3 channels
but after run the code , it show only one chanel like this

shape of image1: (1554,2560,3)
shape of image2: (1554,2560,3)
ssim of per channel:
(0.9802379911743933, 0.0, 0.0, 0.0)

Process finished with exit code 0

i am sorry for boring you !

image quality python bindings feature

All 5 comments

is there any way to avoid this bug @alalek ?

/cc @clunietp @krshrimali

@chenchuangc ,

This is operating as intended, though the usage isn't as intuitive as I'd like for Python users. The Python interface requires that images are passed as lists rather than single images. Try this instead:

ssim_scalar ,map= cv.quality.QualitySSIM_compute([mat2],[mat1])  # use lists for images

In the future, I would like to refactor the interface to accept InputArray rather than InputArrayofArrays. This will align the interface more closely with the rest of OpenCV and allow more straightforward usage, especially in Python.

@alalek , this is not a bug. Can we close this issue or change this to 'Enhancement`? Thanks

thank you so much! @alalek @clunietp

@chenchuangc , the PR was merged, therefore newer opencv_contrib builds will no longer require/accept lists in python. In the future, you will need to change your code back to what you had originally, eg:

ssim_scalar ,map= cv.quality.QualitySSIM_compute( mat2,  mat1 )

Thanks for prompting this API fix!

Was this page helpful?
0 / 5 - 0 ratings