4

I have been reading this paper where they have used Error Level Analysis (ELA) and Block Artifact Grid (BAG).

I have found a way to do the ELA using skimage from here

I want a final output of the BAG part showed in the diagram below [Look at the BAG output specifically] - enter image description here

But I haven't found a single implementation of BAG in python:

  • Divide the image into 8 × 8 blocks. Take the DCT of the blocks (using an 8 × 8 DCT matrix and matrix multiply).
  • Make a histogram of the color-quantized DCT values for each of the 64 locations of the blocks (where the number of blocks and the number of values in each histogram is equal to the number that can fit into the image).
  • Take the Fast-Fourier Transform (FFT) of the histogram of each of the 64 frequencies to get the periodicity and then power spectrum to get peaks.
  • Calculate the number of local minimums of the extrema. This is the estimated Q value.
  • Get a Q estimate for at least 32 Q values, and use it to calculate the block artifact (error in the Q value) for each image block. Output an error map of the image.

What I have tried

I can try and figure out individual pieces like taking DCT, calculating FFT but unable to put everything together, especially Q estimate for at least 32 Q values, which is not making sense to me. Thanks in advance.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Vivek Kalyanarangan
  • 8,951
  • 1
  • 23
  • 42
  • if you can't "find a code", you have to write it. you'd benefit from having a paper that explains this "algorithm" and perhaps even provides a reference implementation. you have a paper, follow its references. the author didn't come up with "BAG". – Christoph Rackwitz Jul 31 '22 at 12:58
  • @ChristophRackwitz thanks for your suggestion, but if you read the question, I _have_ tried implementing it on my own, I am not asking you to do my homework. I have also specified precisely where I am stuck. If you want to know what I have done so far, ask and I will edit my question, didn't want to clutter it with ~50 odd LOC I have come up with so far – Vivek Kalyanarangan Jul 31 '22 at 14:09
  • You should try to contact the authors of the paper and ask them which implementation of BAG they have used. There is [code](https://github.com/IPOL-Fork/jpeg-god) for an [NFA/"A Contrario" based method](https://www.ipol.im/pub/art/2020/283/) for BAG analysis on the net. But that is probably not what you are looking for? – Markus Jul 31 '22 at 15:26
  • Maybe this might help you: https://github.com/matloff/imagefraud which contains code for BAG localization. (NOTE: I haven't tried it myself.) – S_Bersier Aug 07 '22 at 11:47

0 Answers0