Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-band image calculation FSIM is Nan value #62

Open
MC1016 opened this issue Feb 26, 2024 · 4 comments
Open

Multi-band image calculation FSIM is Nan value #62

MC1016 opened this issue Feb 26, 2024 · 4 comments

Comments

@MC1016
Copy link

MC1016 commented Feb 26, 2024

When the code calculates FSIM for multi-band data, the actual single-band results are averaged, and the calculations are all Nan-valued, even with my randomly generated matrices

@MC1016
Copy link
Author

MC1016 commented Feb 26, 2024

The problem may be in the PC component; the 4th element of the PC is all zero, but I don't know why.

@seedlit
Copy link
Contributor

seedlit commented Feb 27, 2024

@MC1016 thanks for reporting.
Can you share minimalist code to reproduce the issue?

@MC1016
Copy link
Author

MC1016 commented Feb 27, 2024

@MC1016 thanks for reporting. Can you share minimalist code to reproduce the issue?
Yes can u try this thanks
from image_similarity_measures.quality_metrics import fsim
def mfsim(y, out):
gts = y
imgs = out
big_res = []

for gt, img in zip(gts, imgs):
    assert gt.shape == img.shape
    res = []
    for ii in range(gt.shape[0]):
        gt_band = gt[ii, :, :][np.newaxis, :, :] * 255
        img_band = img[ii, :, :][np.newaxis, :, :] * 255
        gt_band = np.transpose(gt_band, (1,2,0))
        img_band = np.transpose(img_band, (1,2,0))
        # NOTE: FSIM expects dynamic range [0, 255]
        res.append(fsim(gt_band, img_band))
    big_res.append(np.mean(res))
return np.mean(big_res)

if name == 'main':
ref = np.random.rand(1,1, 3, 3)
tar = np.random.rand(1,1, 3, 3)

print(mfsim1(ref,tar))

@MC1016
Copy link
Author

MC1016 commented Feb 27, 2024

data structure [batch,channel,x,y]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants