compare_psnr()函数报错
为了求ssim这个代码真的烦了好久了
ValueError: win_size exceeds image extent. If the input is a multichannel (color) image, set multichannel=True.
把两个图像的维度以及np 、torch形式改了又改,真的确定维度完全一致了,还是报错。
sian_weights, full, **kwargs)
151 if np.any((np.asarray(im1.shape) - win_size) < 0):
152 raise ValueError(
--> 153 "win_size exceeds image extent. If the input is a multichannel "
154 "(color) image, set multichannel=True.")
155
根据报错提示,是np.any((np.asarray(im1.shape) - win_size) < 0):
structural_similarity(im1, im2, win_size, gradient, data_range, multichannel, gaussian_weights, full, **kwargs)
所以查了win_size的含义,
win_size: int or None, optional
用来比对的滑动窗口的变长。必须是奇数。如果gaussian_weights是True,将其忽略,窗口尺寸将依赖于sigma
看报错的意思就是不能让他小于0,于是直接给win_size定义了数值
win_size = 3(只能定义为奇数)
ssim_value = compare_ssim(img_gt, img_u, win_size = 3, multichannel=True)
运行成功 !!!、
快去试试吧