【发布时间】:2019-05-24 19:16:41
【问题描述】:
我正在使用 TensorFlow 解决图像超分辨率问题(2D 和 3D),并使用 SSIM 作为eval_metrics 之一。
我正在使用来自 TF 的 image.ssim 和来自 skimage 的 measure.comapre_ssim。它们都给出了相同的 2D 结果,但 3D 体积的结果总是存在差异。
我查看了TF-implementation 和skimage-implemenation 的源代码。在两种实现中如何考虑和处理输入图像似乎存在一些根本差异。
复制问题的代码:
import numpy as np
import tensorflow as tf
from skimage import measure
# For 2-D case
np.random.seed(12345)
a = np.random.random([32, 32, 64])
b = np.random.random([32, 32, 64])
a_ = tf.convert_to_tensor(a)
b_ = tf.convert_to_tensor(b)
ssim_2d_tf = tf.image.ssim(a_, b_, 1.0)
ssim_2d_sk = measure.compare_ssim(a, b, multichannel=True, gaussian_weights=True, data_range=1.0, use_sample_covariance=False)
print (tf.Session().run(ssim_2d_tf), ssim_2d_sk)
# For 3-D case
np.random.seed(12345)
a = np.random.random([32, 32, 32, 64])
b = np.random.random([32, 32, 32, 64])
a_ = tf.convert_to_tensor(a)
b_ = tf.convert_to_tensor(b)
ssim_3d_tf = tf.image.ssim(a_, b_, 1.0)
ssim_3d_sk = measure.compare_ssim(a, b, multichannel=True, gaussian_weights=True, data_range=1.0, use_sample_covariance=False)
s_3d_tf = tf.Session().run(ssim_3d_tf)
print (np.mean(s_3d_tf), ssim_3d_sk)
在 3D 情况下,我必须取输出的平均值,因为 Tensorflow 在最后三个维度上计算 SSIM,因此会产生 32 个 SSIM 值。这表明 TF 会考虑 NHWC 格式的 SSIM 图像。这对 SSIM 超过 3D 体积有好处吗?
skimage 然而,似乎正在使用一维高斯滤波器。很明显,即使这样也没有考虑 3D 体积的深度。
有人可以对这些有所了解并帮助我决定进一步使用哪一个以及为什么?
【问题讨论】:
标签: python-2.7 tensorflow image-processing scikit-image ssim