image
本文主要是解决从两张图中寻找不同之处,类似于“找茬”小游戏。为了比较两张图片的结构化差异,寻找两张图中的不同,引入了Structural Similarity Index 指标。而这个指标直接scikit-image 库中集成,可直接调用。
环境依赖:OpenCV, scikit-image, imutils。
image
Figure 1: Manually inspecting the difference between two input images (source).可观察左右两张图的不同。
compare_ssim 函数用来计算两张图片之间的结构化相似度。返回两个参数:score和 diff:
The score represents the structural similarity index between the two input images. This value can fall into the range [-1, 1] with a value of one being a “perfect match”.
The diff image contains the actual image differences between the two input images that we wish to visualize. The difference image is currently represented as a floating point data type in the range [0, 1] so we first convert the array to 8-bit unsigned integers in the range [