jterrace / pyssim

A Python module for computing the Structural Similarity Image Metric (SSIM)
MIT License
340 stars 62 forks source link

CW-SSIM: Are summation axises mixed? #37

Open aneepi opened 4 years ago

aneepi commented 4 years ago

Hello!

I checked the CW-SSIM calculation part and I realized that there is something fishy in the summation axises. scipy.signal.cwt returns continuous wavelet transformations as numpy.ndarray with output shape (M,N), where M is the number of width parameters given and N is the lenght of the input array. On other words, there should be numpy.sum(..., axis=1) intstead of numpy.sum(..., axis=0). This way CW-SSIM is calculated within one width parameter and then averaged over the different transformations.

I would also add some notification or comment, which tells that CWT in scipy is done in 1D even though image actually is in 2D.

jterrace commented 4 years ago

You may be right, I honestly don't know. Any other reference implementation we could compare it to?

jterrace commented 4 years ago

paging @chaosmail who wrote this

aneepi commented 4 years ago

In the original paper of Zhou Wang and E.P. Simoncelli, Translation insensitive image similarity in complex wavelet domain, authors write: "cx=... and cy=... are two sets of coefficients extracted at the same spatial location in the same wavelet subbands of the two images being compared, respectively."

Later in the "Test" section they describe process as:

"To apply the CW-SSIM measure for comparing images, we first decompose the two given images being compared using a complex version [6] of the “steerable pyramid” transform [7] (a type of redundant wavelet transform that avoids aliasing in subbands). We then move a sliding window (of size 7×7) step by step across each wavelet subband. At each step, the CW-SSIM index is calculated within the sliding window using Eq. (4). The overall similarity of the two images is estimated using the average of the local CW- SSIM measures in all subbands (or a subset of all the subbands)."

According to these I'd say that the original CW-SSIM is calculated in a similar fashion as SSIM using sliding windows over the image, which has been subjected to CWT. The results are averaged within a subbands, which I think here means a one width parameter of the used wavelet. In the end these results can also be averaged over a subbands.

I have been making some research using similar ideas as in CW-SSIM and I got some weird results with summations with the ordering mentioned in the first post. However, I was not totally sure.

jterrace commented 4 years ago

You're welcome to submit a pull request. I honestly didn't look that closely when @chaosmail implemented it.

Hs-Cheng commented 1 year ago

Hello everyone,

I would like to ask if the CW-SSIM results are correct right now. Could you please give me an update on this issue?

Thank you very much.