当前位置:   article > 正文

A deep learning approach to detection of splicing and copy-move forgeries in images_srm滤波器

srm滤波器

https://github.com/kPsarakis/Image-Forgery-Detection-CNNhttps://github.com/kPsarakis/Image-Forgery-Detection-CNN

        代码是结合代尔夫特理工大学的deep learning这门课的大作业来讲的。整体上一个分类的框架,但是用了srm噪声提取器,这个后来被RGBN作为双流fasterrcnn中的噪声流支路引用,srm在篡改检测中是比较常见的人工设计的算子。这篇文章的代码我跑过,本身还是有效果的,其中它里面数据预训练的分patch操作也在后续中被引进,但说实话,这种简单的网络设计其实跑不过不做任何设计的分类模型,比如res2net。篡改检测常用的基本都是自然场景数据集,比如CASIA1/2,中科院出的数据集,还有BHSig60,COVERAGE,NC16等,这些数据集的篡改手段包括了resize,压缩啊这些操作,其实和常规的文档类的数据集的ps还是有差别的,我们常说自然场景和文档篡改的差别挺大的,文档主要还是以ps这种操作为主。

上面这张图是网络设计,核心是第一组蓝色的cnn操作,这里面融合例如srm滤波器。srm滤波器最早出自于Rich models for steganalysis of digital images中,是Steganalysis Rich Model的缩写,富隐写分析模型,篡改操作会带来十分尖锐的边缘,尤其是拼接操作,会被高通滤波器很明显的体现出来。文章在cnn的结构里对第一层卷积的权重使用30个在srm中九三残差图的基本高通滤波器进行初始化,这些基础的滤波器对应了7个srm残差类别,分布如下:

个数滤波器类别
81st
42nd
83rd
1SQUARE3x3
4EDGE3x3
1SQUARE5x5
4EDGE3x3
  1. from typing import Dict
  2. import numpy as np
  3. from torch import Tensor, stack
  4. def get_filters():
  5. """
  6. Function that return the required high pass SRM filters for the first convolutional layer of our implementation
  7. :return: A pytorch Tensor containing the 30x3x5x5 filter tensor with type
  8. [number_of_filters, input_channels, height, width]
  9. """
  10. filters: Dict[str, Tensor] = {}
  11. # 1st Order
  12. filters["1O1"] = Tensor(np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, -1, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]))
  13. filters["1O2"] = Tensor(np.rot90(filters["1O1"]).copy())
  14. filters["1O3"] = Tensor(np.rot90(filters["1O2"]).copy())
  15. filters["1O4"] = Tensor(np.rot90(filters["1O3"]).copy())
  16. filters["1O5"] = Tensor(np.array([[0, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, -1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]))
  17. filters["1O6"] = Tensor(np.rot90(filters["1O5"]).copy())
  18. filters["1O7"] = Tensor(np.rot90(filters["1O6"]).copy())
  19. filters["1O8"] = Tensor(np.rot90(filters["1O7"]).copy())
  20. # 2nd Order
  21. filters["2O1"] = Tensor(np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 1, -2, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]))
  22. filters["2O2"] = Tensor(np.rot90(filters["2O1"]).copy())
  23. filters["2O3"] = Tensor(np.array([[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, -2, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0]]))
  24. filters["2O4"] = Tensor(np.rot90(filters["2O3"]).copy())
  25. # 3rd Order
  26. filters["3O1"] = Tensor(np.array([[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, -3, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]))
  27. filters["3O2"] = Tensor(np.rot90(filters["3O1"]).copy())
  28. filters["3O3"] = Tensor(np.rot90(filters["3O2"]).copy())
  29. filters["3O4"] = Tensor(np.rot90(filters["3O3"]).copy())
  30. filters["3O5"] = Tensor(np.array([[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, -3, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0]]))
  31. filters["3O6"] = Tensor(np.rot90(filters["3O5"]).copy())
  32. filters["3O7"] = Tensor(np.rot90(filters["3O6"]).copy())
  33. filters["3O8"] = Tensor(np.rot90(filters["3O7"]).copy())
  34. # 3x3 SQUARE
  35. filters["3x3S"] = Tensor(np.array([[0, 0, 0, 0, 0], [0, -1, 2, -1, 0], [0, 2, -4, 2, 0], [0, -1, 2, -1, 0], [0, 0, 0, 0, 0]]))
  36. # 3x3 EDGE
  37. filters["3x3E1"] = Tensor(np.array([[0, 0, 0, 0, 0], [0, -1, 2, -1, 0], [0, 2, -4, 2, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]))
  38. filters["3x3E2"] = Tensor(np.rot90(filters["3x3E1"]).copy())
  39. filters["3x3E3"] = Tensor(np.rot90(filters["3x3E2"]).copy())
  40. filters["3x3E4"] = Tensor(np.rot90(filters["3x3E3"]).copy())
  41. # 5X5 EDGE
  42. filters["5x5E1"] = Tensor(np.array([[-1, 2, -2, 2, -1], [2, -6, 8, -6, 2], [-2, 8, -12, 8, -2], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]))
  43. filters["5x5E2"] = Tensor(np.rot90(filters["5x5E1"]).copy())
  44. filters["5x5E3"] = Tensor(np.rot90(filters["5x5E2"]).copy())
  45. filters["5x5E4"] = Tensor(np.rot90(filters["5x5E3"]).copy())
  46. # 5x5 SQUARE
  47. filters["5x5S"] = Tensor(np.array([[-1, 2, -2, 2, -1], [2, -6, 8, -6, 2], [-2, 8, -12, 8, -2], [2, -6, 8, -6, 2], [-1, 2, -2, 2, -1]]))
  48. return vectorize_filters(filters)
  49. def vectorize_filters(filters: dict):
  50. """
  51. Function that takes as input the 30x5x5 different SRM high pass filters and creates the 30x3x5x5 tensor with the
  52. following permutations
    声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/414982
    推荐阅读
    相关标签