IRACST - International Journal of Computer Science and Information Technology & Security (IJCSITS), ISSN: 2249-9555
Vol.7, No.2, Mar-April 2017
Fake Image Detection Using Machine Learning
Muhammed Afsal Villan Kuncheria Kuruvilla
Department of Computer Science and Engineering Department of Computer Science and Engineering
Mar Athanasius College of Engineering, Kothamangalam Mar Athanasius College of Engineering, Kothamangalam
Kerala, India Kerala, India
Email:afsalashyana@[Link] Email:kuncheria94@[Link]
Johns Paul Prof. Eldo P Elias
Department of Computer Science and Engineering Department of Computer Science and Engineering
Mar Athanasius College of Engineering, Kothamangalam Mar Athanasius College of Engineering, Kothamangalam
Kerala, India Kerala, India
Email:johnspaul007@[Link] Email:eldope@[Link]
Abstract—Many fake images are spreading through digital Implementation details while the last part showcase the
media nowadays. Detection of such fake images is inevitable for experimental result.
the unveiling of the image based cybercrimes. Forging images
and identifying such images are promising research areas in this
digital era. The tampered images are a detected using neural
II. THEORY
network which also recognizes the regions of the image that have
been manipulated and reveals the segments of the original image. A. Metadata Analysis
It can be implemented on Android platform and hence made
available to common users. The compression ratio of the foreign
Most image files do not just contain a picture. They also
content in a fake image is different from that of the original contain information (metadata) about the picture. Metadata
image and is detected using Error Level Analysis. Another provides information about a picture's pedigree, including the
feature used along with compression ratio is image metadata. type of camera used, color space information, and application
Although it is possible to alter metadata content making it notes. Different picture formats include different types of
unreliable on its own, here it is used as a supporting parameter metadata. Some formats, like BMP, PPM, and PBM contain
for error level analysis decision very little information beyond the image dimensions and color
space. In contrast, a JPEG from a camera usually contains a
Keywords -- Image forensics, Metadata analysis, Error level wide variety of information, including the camera's make and
analysis, Multilayer perception network, Deep neural networks model, focal and aperture information, and timestamps.
PNG files typically contain very little information, unless
I. INTRODUCTION the image was converted from a JPEG or edited with
In this technological era a huge number of people have Photoshop. Converted PNG files may include metadata from
become victims of image forgery. A lot of people use the source file format.
technology to manipulate images and use it as evidences to
Metadata provides information related to how the file was
mislead the court. So to put an end to this, all the images that
generated and handled. This information can be used to
are shared through social media should be categorized as real
identify if the metadata appears to be from a digital camera,
or fake accurately. Social media is a great platform to socialize,
processed by a graphical program, or altered to convey
share and spread knowledge but if caution is not exercised, it
misleading information. Common things to look for include:
can mislead people and even cause havoc due to unintentional
false propaganda. While manipulation of most of the 1) Make, Model, and Software
photoshoped images is clearly evident due to pixelization &
shoddy jobs by novices, some of them indeed appear genuine. These identify the device or application that created the
Especially in the political arena, manipulated images can make picture. Most digital cameras include a Make and Model in
or break a politician’s credibility. the EXIF metadata block. (However, the original iPhone
does not!) The Software may describe the camera's firmware
Current forensic techniques require an expert to analyze the version or application information.
credibility of an image. We implemented a system that can
determine whether an image is fake or not with the help of 2) Image size
machine learning and thereby making it available for the The metadata often records the picture's dimensions. Does
common public. This paper will unfold into three sections the rendered image size (listed at the bottom of the metadata)
whereby first will focus on the second will focus on the match the other sizes in the metadata? Many applications resize
or crop pictures without updating other metadata fields.
19
IRACST - International Journal of Computer Science and Information Technology & Security (IJCSITS), ISSN: 2249-9555
Vol.7, No.2, Mar-April 2017
3) Timestamps Books on the shelf were duplicated and a toy dinosaur was
added to the shelf. The 95% ELA identifies the changes since
Look for fields that detail timestamps. These typically they are areas that are no longer at their minimal error level.
identify when a picture was taken or altered. Do the timestamps Additional areas of the picture show slightly more volatility
match the expected timeframe? because Photoshop merged information from multiple layers,
4) Types of metadata effectively modifying many of the pixels. Nearly all pixels in
the original image are not at their local minima. The first resave
There are many different metadata types. Some are only (75%) shows large areas where the pixels have reached their
generated by cameras, while others are only generated by local minima. The second resave introduces more areas that
applications. have reached their local minima for error.
5) Descriptions By analyzing the pattern in the ELA applied image (Fig 1
Many pictures include embedded annotations that describe left part), we can determine which part of the image is possibly
the photo, identify the photographer, or itemize alteration steps. faked. It is hard for the human eye to detect small scale
changes to image so that we have decided to use machine
6) Missing metadata learning to detect the anomalies in the error level analyzed
Are any metadata fields missing? If the picture came from a images.
digital camera, then it should have camera-specific
information. Some applications and online services strip out
metadata. A lack of specific metadata usually indicates a
resaved picture and not an original photo.
7) Altered Metadata
Metadata is analogous to the chain of custody for evidence
handing. It can identify how a picture was generated,
processed, and last saved. However, some people intentionally
alter metadata. They may edit timestamps or photo information Fig 1. Error level analyzed image on the left and fake image on the right
in an attempt to deceive
B. Error Level Analysis C. Machine Learning
JPEG is a lossy format, but the amount of error introduced The process of machine learning is similar to that of data
by each resave is not line. Any modification to the picture will mining. Both systems search through data to look for patterns.
alter the image such that stable areas (no additional error) However, instead of extracting data for human comprehension
become unstable. Fig.1 shows a modified image using as is the case in data mining applications machine learning uses
Photoshop. The modified picture was based on the first 75% that data to detect patterns in data and adjust program actions
resave. Books on the shelf were duplicated and a toy dinosaur accordingly. Machine learning algorithms are often
was added to the shelf. The 95% ELA identifies the changes categorized as being supervised or unsupervised. Supervised
since they are areas that are no longer at their minimal error algorithms can apply what has been learned in the past to new
level. Additional areas of the picture show slightly more data. Unsupervised algorithms can draw inferences from
volatility because Photoshop merged information from multiple datasets.
layers, effectively modifying many of the pixels.
Facebook's News Feed uses machine learning to
A 90% image resaved at 90% is equivalent to a one-time personalize each member's feed. If a member frequently stops
save of 81%. Similarly, saving an image at 75% and then scrolling in order to read or "like" a particular friend's posts, the
resaving it at 90% (75% 90%) will generate virtually the same News Feed will start to show more of that friend's activity
image as 90% 75%, or saved once at 67.5%. 19 The amount of earlier in the feed. Behind the scenes, the software is using
error is limited to the 8x8 cells used by the JPEG algorithm; statistical analysis and predictive analytics to identify patterns
after roughly 64 resaves, there is virtually no change. However, in the user's data and use to patterns to populate the News Feed.
when an image is modified, the 8x8 cells containing the They observe the activities of the user like, comment, share etc
modifications are no longer at the same error level as the rest of on various posts and based on these activities the contents on
the unmodified image. Error level analysis (ELA) works by the news feed will be adjusted continuously.
intentionally resaving the image at a known error rate, such as
95%, and then computing the difference between the images. If
there is virtually no change, then the cell has reached its local III. SYSTEM DESIGN
minima for error at that quality level. However, if there is a
large amount of change, then the pixels are not at their local A. Metadata Analysis
minima and are effectively “original”. JPEG is a lossy format, The entire system is developed using java programming
but the amount of error introduced by each resave is not linear language. For extracting metadata of images, metadata -
modification to the picture will alter the image such that stable extractor library is used. Metadata-extractor [5] is able to
areas (no additional error) become unstable [1].
20
IRACST - International Journal of Computer Science and Information Technology & Security (IJCSITS), ISSN: 2249-9555
Vol.7, No.2, Mar-April 2017
extract metadata information of large no of different image propagation learning rule. The structure of neural network is
types. Once an image is selected for processing, it is tunneled shown in Table 2.
into 2 separate stages. First stage is metadata analysis. After
extracting metadata, the metadata text is fed into metadata A multilayer perceptron neural network is used having one
analysis module. input layer, 3 hidden layers and 1 output layer. Once the image
is selected for evaluation, it is converted to ELA representation
Metadata analyzer is basically a tag searching algorithm. If from Compression and Error Level Analysis stage. 100%, 90%
keywords like Photoshop, Gimp, Adobe etc. is found in the text images are used for the construction of ELA image
and then the possibility of being tampered is increased. Two
separate variables are maintained which are called fakeness and Once ELA is calculated, the image is preprocessed to
realness. Each variable represents the weight of being real or convert into 100x100px width and height. After preprocessing,
fake image. Once a tag is taken, it is analyzed and the image is serialized in to an array. The array contains 30,000
corresponding variable is incremented by a certain predefined integer values representing 10,000 pixels. Since each pixel has
weight. The following table represents keywords and red, green and blue components, 10,000 pixels will have
corresponding weight increments. After processing the entire 30,000 values.
tags, final values of fakeness and realness variable is fed into During training, the array is given as input to the multilayer
the output stage as shown in Fig 2. perceptron network and output neurons also set. The MLP is a
Table 1. Keyword listing fully connected neural network. There are 2 output neurons.
First neuron is for representing fake and the second one for real
Keyword Realness / Fakeness Inc. Value image. If the given image is fake one, then the fake neuron is
Photoshop Fakeness 5 set to one and real is set to zero. Else fake is set to zero and real
set to one.
Gimp Fakeness 5
We have used momentum backpropagation learning rule
Corel Fakeness 5 adjust the neuron connection weights. It is a supervised
learning rule that tries to minimize the error function. The
Adobe Fakeness 3 chosen learning rate and momentum along with achieved
Exif Info Realness 2 efficiency is given in Table 3.
Camera Tags Realness 2 During testing, the image array is fed into the input neurons
and values of output neurons are taken. We have used sigmoid
B. Error Level Analysis activation function.
Error level analysis is done with the help of ImageJ [2] Table 2. Structure of Neural Network
Layer Remarks
Input Layer 30,000 neurons
5000 neurons, Sigmoid
Hidden Layer 1
activation function
1000 neurons, Sigmoid
Hidden Layer 2
activation function
100 neurons, Sigmoid
Fig 2. Flow chart of the system Hidden Layer 3
activation function
Output Layer 2 neurons
library. ImageJ provides option to save image in JPEG format
with certain percentage of compression. The system first saves
an image at 100% quality. Then the same image is converted
into 90% quality image using ImageJ. The difference between
these two is found out though difference method. The resulting
image is the required ELA image of the input image. This
image is saved as a buffered image and sent to the neural
network for further processing.
C. Machine Learning
Machine learning is implemented using Neuroph [4] library
for java. Neuroph is selected because of the simplicity and
easiness to implement neural networks. We have implemented
a multilayer perceptron network with momentum back
Fig 3. Neuroph framework configurations 21
IRACST - International Journal of Computer Science and Information Technology & Security (IJCSITS), ISSN: 2249-9555
Vol.7, No.2, Mar-April 2017
IV. EXPERIMENTAL RESULT
V. CONCLUSION
Metadata analysis has shown promising result in non-shared
Neural network has been successfully trained using the
images. It is able to detect anomaly in all ‘photoshopped’ or
error level analysis with 4000 fake and 4000 real images. The
‘gimped’ images under a very small processing. It failed on
trained neural network was able to recognize the image as fake
images shared through WhatsApp, Google+ etc. Moreover, it
or real at a maximum success rate of 83%. The use of this
became completely erroneous when images with manipulated
application in mobile platforms will greatly reduce the
metadata given.
spreading of fake images through social media. This project
Neural network is trained with CASIA dataset [3]. The can also be used as a false proof technique in digital
dataset contains 7491 real images and 5123 tampered images authentication, court evidence evaluation etc. By combining the
under varying sizes. All the images are preprocessed to results of metadata analysis (40%) and neural network output
100x100 pixels so that total pixel values to be fed into the (60%) a reliable fake image detection program is developed
neural network will be 30,000. From the dataset we have used and tested. The complete project is available in GitHub [6].
4000 real and fake images for training. Remaining images were
used for testing of the neural network. Table 3 shows various REFERENCES
neural network configurations and corresponding neural
[1] A picture’s worth, Digital Image Analysis and Forensics, N Krawetz -
network efficiency. Best is achieved when learning rate set to 2007 Ph D, Hacker Factor Solutions
0.2 and momentum to 0.7. [2] [Link]
Table 3. Neural network training results ImageJ is an open source image processing program designed for
scientific multidimensional images.J. Clerk Maxwell, A Treatise on
Learning Electricity and Magnetism, 3rd ed., vol. 2. Oxford: Clarendon, 1892,
Momentum Epoch Efficiency
Rate pp.68–73.
[3] [Link] CASIA v2.0
0.01 0.5 500 60%
CASIA V2.0 is with larger size and with more realistic and challenged
0.05 0.5 500 62% fake images by using post-processing of tampered regions. It contains
7491 authentic and 5123 tampered color images.
0.1 0.5 500 68% [4] [Link] Neuroph Framework
Neuroph is lightweight Java neural network framework to develop
0.2 0.5 500 66% common neural network architectures. It contains well designed, open
source Java library with small number of basic classes which correspond
0.1 0.4 500 69% to basic NN concepts.
0.1 0.3 500 68% [5] [Link]
Metadata-extractor is a straightforward Java library for reading metadata
0.1 0.6 500 75% from image files.
0.1 0.7 500 76%` [6] [Link]
GitHub repositor for fake image detector desktop application written in
0.2 0.7 500 82% javafx.
0.2 0.7 1000 83%
22