我正在计算两幅图像之间的结构相似性指数。我不明白这个维度应该是什么。这两个图像(引用和目标)都是RGB图像。
如果我将我的图像塑造为(256*256,3),我得到:
ref = Image.open('path1').convert("RGB")
ref_array = np.array(ref).reshape(256*256, 3)
print(ref_array.shape) # (65536, 3)
img = Image.open('path2').convert("RGB")
img_array = np.array(img).reshape(256*256, 3)
print(img_array.shape) # (65536, 3)
ssim = compare_ssim(ref_array,img_array,multichannel=True,data_range=255)结果是0.0786。
另一方面,如果我重塑为(256,256,3):
ref = Image.open('path1').convert("RGB")
ref_array = np.array(ref)
print(ref_array.shape) # (256, 256, 3)
img = Image.open('path2').convert("RGB")
img_array = np.array(img)
print(img_array.shape) # (256, 256, 3)
ssim = compare_ssim(ref_array, img_array, multichannel=True, data_range=255)结果是0.0583
这两个结果中哪一个是正确的,为什么?文档没有提到任何关于它的内容,因为它可能是一个概念性的问题。
发布于 2020-03-12 19:08:00
第二个是正确的,假设你有一个方形的图像,而不是一个很长很薄的图像。
SSIM考虑到相邻像素(用于亮度和色度掩蔽和识别结构)。图像可以是任意形状,但是如果你告诉算法你的形状是256*256×1像素,那么垂直结构就不会被考虑在内。
https://stackoverflow.com/questions/60660310
复制相似问题