Matlab implementation of digital camera fingerprint extraction (maximum likelihood formula [1]), removal of non-unique artifacts (NUA) from fingerprints, extraction of noise residual from images, and calculation of Peak-correlation-to-correlation-ratio (PCE) detection statistic is shared.
In a number of our forensics publications [1-7] we utilize Photo-Response Non-Uniformity (PRNU) as a unique fingerprint of digital cameras. The provided code is consistent with the one used in large scale test of camera identification [1].
Three main functions and two examples how to use them are provided here:
getFingerprint.m - Estimation of camera fingerprint consisting of Photo-Response Non-Uniformity (PRNU) noise and traces of dark current. Color images from one source camera are processed to output the camera fingerprint. The images filenames must be listed in Images structure. An example is included in the header comments of getFingerprint.m.
PCE.m - Like normalized correlation, Peak-to-Correlation Energy ratio (PCE) is a measure of similarity for two discrete signals. PCE is especially suitable for 2-dimensional camera fingerprints because presence of hidden periodic patterns (a latent source of false identification) decreases PCE. This implementation involves a fast cross-correlation computation using FFT.
NoiseExtractFromImage.m - Extraction of image noise residual from a color or grayscale image.
Example.m - A simple example of how to use this code for the camera identification problem.
A collection of supportive functions is in \Functions while noise extraction is in \Filter directory. Wavelet transform functions mdwt.dll and midwt.dll were compiled under 32-bit Windows operating system. The source code provided by Rice University is included. Run mex command if you need to compile it under different OS (see compile.m).
Two steps in noise residual filtering are necessary in order to remove inherent embedded signals common to cameras of the same model. A special signal called "linear pattern" is removed by ZeroMeanTotal.m. Both getFingerprint.m and NoiseExtractFromImage.m contain this step already. The second step realized by WienerInDFT.m substantially removes JPEG and other periodic artifacts by supressing peaks in Fourier domain. This step has to be added as shown in Example.m. Skipping this step will significantly lower PCE and increase error rates. Additional information can be found in the F.A.Q. section below.
The provided code is available for research purposes. Please, remember to recognize our work by citing [1] and/or our newer publications. Thank you.
The Camera Fingerprint Program is protected by U.S. copyright law. This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License, and you may not use the program for commercial purposes without express written permission from the copyright holder. For permission, contact Scott Moser smoser@binghamton.edu.
[1] M. Goljan, J. Fridrich, and T. Filler, Large Scale Test of Sensor Fingerprint Camera Identification.. In N.D. Memon and E.J. Delp and P.W. Wong and J. Dittmann, editors, Proc. of SPIE, Electronic Imaging, Media Forensics and Security XI, volume 7254, pages 0I-010I-12, January 2009.[pdf]
[2] M. Goljan, J. Fridrich, Camera Identification from Scaled and Cropped Images.. In E. J. Delp et al., ed.,'Electronic Imaging, Security, Forensics, Steganography, and Watermarking of Multimedia Contents X', SPIE, pp. 68190E, 2008.[pdf]
[3] M. Goljan, J. Fridrich, and M. Chen, Countering Counter-Forensics.. In N.D. Memon; J. Dittmann & A. Alattar, ed.,'Proceeedings of SPIE Electronic media Forensics and Security XII', vol.7541, pp. 0S-010S-12, 2010.[pdf]
[4] M. Goljan, J. Fridrich, and M. Chen, Defending Against Fingerprint-Copy Attack in Sensor-Based Camera Identification.. In IEEE Transactions on Information Security and Forensics 6(1), 227-236, 2010.[pdf]
[5] M. Goljan, J. Fridrich, and T. Filler, Managing a Large Database of Camera Fingerprints.. In N.D. Memon; J. Dittmann & A. Alattar, ed.,'Proc. SPIE Electronic Imaging, Steganography, Security, and Watermarking of Multimedia Contents XII', vol.7541, pp. 08-0108-12, 2010.[pdf]
[6] J. Fridrich, M. Goljan, Determining Approximate Age of Digital Images Using Sensor Defects.. In 'Proceeedings of SPIE, Media Watermarking, Security, and Forensics XIII', pp. 06-0106-11, 2011.[pdf]
[7] M. Goljan, J. Fridrich, Sensor-Fingerprint Based Identification of Images Corrected for Lens Distortion.. In 'Proceeedings of SPIE, Media Watermarking, Security, and Forensics 2012', 2012.
Q: GetFingerprint runs out of memory. What should I do?
A: In case the images are not overexposed and lack white saturated areas you can skip the correction for saturation without loss of fingerprint quality. We did not include this option in the code but you can do the following:
Replace lines 90 to 92
Inten = single(IntenScale(X(:,:,j))).*Saturation(X(:,:,j));
RPsum{j} = RPsum{j}+ImNoise.*Inten;
NN{j} = NN{j} + Inten.^2;
with
% line 90 removed
RPsum{j} = RPsum{j}+ImNoise.*X(:,:,j);
NN{j} = NN{j} + X(:,:,j).^2;
If the memory issue persists you can reduce the size of the data by cropping the images to a smaller size, using imcropmiddle.m, for example.
Q: Do I need any additional packages or libraries?
A: You need discrete wavelet transforms such as those included in \Filter directory as dll (developed by Markus Lang from Rice University). These .dll run under 32-bit Windows only. You may need to recompile them uder your operating system if different.
Here, you can download commented MATLAB code that was used to generate the results in the referenced publication.
Miroslav Goljan, Mo Chen, Pedro Comesaand Jessica Fridrich, Effect of Compression on Sensor-Fingerprint Based Camera Identification. Media Watermarking, Security, and Forensics 2016, Proceedings of Electronic Imaging, 2016, San Francisco, CA.