比较不同分辨率的图像 [英] Comparing images with different resolutions

查看:167
本文介绍了比较不同分辨率的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能比较具有不同分辨率的两个图像吗?



我的意思是这里的一些算法/编程方法。例如,现在我从图像的字节数组计算哈希码并比较这些哈希码值。这是很好的但是在不同分辨率的情况下失败,即图像通过眼睛是相同的,但是字节内容不同。



例如,请参阅我的图片附件:



其中一个具有 72 ppi ,但另一个 96 ppi 。我想在比较平等时有 TRUE 值,但现在我得到 FALSE

解决方案

两个非常简单的感知哈希方法,你可以尝试之前冒险到更复杂的领域是基于离散余弦变换和图像的局部vs全局平均​​值:


  1. 将图像转换为灰度



    1.1(编辑)将图片设为零意味着


  2. 将图片缩小为缩图大小,例如[32x32] >
  3. 运行二维离散余弦变换

  4. 保留左上角[8 x 8],最显着的低频分量


  5. 结果是64位散列

此主题的变体是


  1. 将图片转换为灰度


  2. 将整个图像分成固定数量的块

  3. 确定全局平均值

  4. 确定每个块的局部平均值

  5. 对于散列,每个块写出1或0,如果本地
    平均值大于或小于全局
  6. > phash 。


    Is there possible to compare two images with different resolutions?

    I mean here some algorithmic/programming approach. For instance, now I calculate hash code from image's byte array and compare these hash code values. That is work great but fail in case of different resolutions, i.e. images are identical by eye but different in it byte content.

    For example see my image attaches:

    one of it has 72 ppi but another 96 ppi. I would like to have TRUE value while comparing on equality but now I get FALSE. Help please to find correct solution here.

    解决方案

    Two very simple perceptual hashing methods you might give a try before venturing into more complicated territory are based on the Discrete Cosine Transform and the local vs glocal mean of an image:

    1. Convert image to grayscale

      1.1 (EDIT) Make your image zero mean

    2. Crush your image down to thumbnail size, say [32x32]
    3. Run the two dimensional Discrete Cosine Transform
    4. Keep the top left [8 x 8], most significant low frequency components
    5. Binarize the block, based on the sign of the components
    6. Result is a 64 bit hash

    And a variant on this theme would be

    1. Convert image to grayscale
    2. Optionally re-size to a predefined size.
    3. Partition the image in a fixed number of blocks
    4. Determine the global mean
    5. Determine the local mean per block
    6. For the hash, write out a 1 or a 0 per block, pending if the local mean was larger or smaller than the global mean.

    Also, have a look at phash.

    这篇关于比较不同分辨率的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆