Journal of Robotics, Networking and Artificial Life
Vol. 7(1); June (2020), pp. 35–40
DOI: https://doi.org/10.2991/jrnal.k.200512.008; ISSN 2405-9021; eISSN 2352-6386
https://www.atlantis-press.com/journals/jrnal

Research Article

Training Autoencoder using Three Different Reversed Color
Models for Anomaly Detection
Obada Al aama1, Hakaru Tamukoh2,*
Department of Life Science and Systems Engineering, Graduate School of Life Science and Systems Engineering, Kyushu Institute of Technology,
2-4 Hibikino, Wakamatsu-ku, Kitakyushu 808-0196, Japan2
Department of Human Intelligence System, Graduate School of Life Science and Systems Engineering, Kyushu Institute of Technology,
2-4 Hibikino, Wakamatsu-ku, Kitakyushu 808-0196, Japan
1

ARTICLE INFOABSTRACT

Article History

Autoencoders (AEs) have been applied in several applications such as anomaly detectors and object recognition systems.
However, although the recent neural networks have relatively high accuracy but sometimes false detection may occur. This
paper introduces AE as an anomaly detector. The proposed AE is trained using both normal and anomalous data based on
convolutional neural network with three different color models Hue Saturation Value (HSV), Red Green Blue (RGB), andour own model (TUV). As a result, the trained AE reconstruct the normal images without change, whereas the anomalous
image would be reconstructed reversely. The training and testing of the AE in case of RGB, HSV, and TUV color models were
demonstrated and Cifar-10 dataset had been used for the evaluation process. It can be noticed that HSV color model has been
more effective and achievable as an anomaly detector rather than other color models based on Z- and F-test analyses.

Received 11 November 2019
Accepted 25 February 2020
Keywords
Convolutional neural network
autoencoder
anomaly detection
color models© 2020 The Authors. Published by Atlantis Press SARL.
This is an open access article distributed under the CC BY-NC 4.0 license (http://creativecommons.org/licenses/by-nc/4.0/).

1. INTRODUCTION

2.1. Autoencoder

The Artificial Intelligence (AI) is widely used and has been existed
over many decades. It uses the information originating from sensors, images, languages and texts. Analyzing this information
giving hypothesis leading to make decision [1]. AI can be viewed
as a set that contains Machine Learning (ML) and Deep Learning(DL) [2]. DL is often categorized as supervised or unsupervised [3].
Autoencoders (AEs) are one of the DL methods which trained in an
unsupervised fashion to automatically extract features of training
data [4]. Moreover, anomaly detection is one of the most important
applications of AEs [5]. One of the training methods that has beenused for anomaly detection is a Convolutional Neural Network(CNN). CNN has been applied in various modern applications,and it is often implemented in image analysis [6], speech and facerecognition [7] and autoencoders [8] with great success.

Autoencoders are neural networks that aims to copy their inputs totheir outputs. It is used to automatically extract features of training data. AEs are applied for object recognition systems that being
used the anomaly detectors [5]. To improve a recognition accuracy, the anomaly detectors has the ability to remove anomalous
objects before recognition process to reduce misrecognition. AEs
are composed of three fully connected layers: input, hidden, andoutput layers. These layers are trained to reconstruct input data on
the output layer as shown in Figure 1.

The aim of this study is to use CNN-autoencoder trained with threedifferent color models; Hue Saturation Value (HSV), Red GreenBlue (RGB) and our own model (TUV) to improve the detection
accuracy especially the anomalous one.

2.2. Anomaly Detection
The idea in anomaly detection based on machine learning, is tomodel the normal behavior of data in the training period, and thentry to fit the test data using the trained model. In case a large inconsistency is found between the fitted model and the trained model,
the test data is regarded as anomalous.

The main concept focuses over using the autoencoder trained withreversed color models in order to detect the anomaly data.

When using autoencoders, which applies dimensionality reduction
to the input data, for anomaly detection, we assume that the datacontains variables that can be represented in lower dimensions.
These variables are also assumed to be correlated with each otherand would show significant difference between normal and anomalous samples [9].

Corresponding author. Email: tamukoh@brain.kyutech.ac.jp

There are two types of training data for autoencoder to detect
anomaly images; labeled and unlabeled data. Based on the type of

2. RESEARCH CONCEPT*

O. Al aama and H. Tamukoh / Journal of Robotics, Networking and Artificial Life 7(1) 35–40

36

a

b

Figure 3 | Converting training dataset images, (a) RGB to HSV, (b) HSV
to TUV.

Hue calculation (H):Figure 1 | Structure of autoencoder.

ì
D=0
0°
ï
ö
ï ° æ G¢ - B¢
ï60 ´ ç D mod6 ÷ , Cmax = R¢èø
ï
H = í ° æ B¢ - R¢ö
+ 2 ÷ , Cmax = G¢
ï60 ´ çè Døïï ° æ R¢ - G¢ö+ 4 ÷ , Cmax = B¢
ï60 ´ ç
D
è
ø
î

(1)



Saturation calculation (S):
ì 0, Cmax = 0
ï
S=í D
(2)
, Cmax ¹ 0
ïC
î max

Value calculation (V):Figure 2 | Block diagram of training method.

V = Cmax (3)where H, S, and V are the component of the HSV image,data, the anomaly detection algorithm differs. In case of labeled
data, conditional distributions can distinguish between correct
and anomalous data. Accordingly, the probability of the conditional distribution determines whether the data is correct oranomalous. On the other hand, a generative model trained withcorrect data is used as a detector for unlabeled data. The inabilityof the model to generate a correct output for anomalous data isutilized to detect anomaly.

3. METHODOLOGY
The autoencoder reconstruct the input to the output even if the
input was an anomalous data, and the Mean Square Error (MSE)
between input and output will be small in case of normal or an
anomalous input, and the detection will be difficult especiallyfor the anomalous one. Our goal is to maximize the differenceof reconstruction error by reconstructing the anomaly classes
reversely. Therefore, the MSE will be bigger and the anomaly
detection will be easier as shown in Figure 2.

3.1. Detection Algorithm
The first step of the algorithm is to convert the training dataset
images from RGB color model to HSV [10] or TUV as shown in
Figure 3a and 3b respectively. Using the Equations (1)–(3) for HSV
color model, and Equations (4)–(6) for TUV color model.

R′ = R/255, G′ = G/255, B′ = B/255.
Cmax = max (R′, G′, B′), Cmin = min (R′, G′, B′), and Δ = Cmax − Cmin
T = S ´ sin H (4)

U = S ´ cos H (5)

V =V 

(6)

Notice in the case of HSV color model the value range for hue, saturation and value are 0–179, 0–255 and 0–255 respectively.
Secondly, the anomalous data is reversed as a result of the next step
as shown in Figure 4, using the following Equations (7)–(9),Rr = 1 - R¢ 

(7)

Gr = 1 - G¢ 

(8)Br = 1 - B¢ 

(9)Consequently, the AE is trained using the new training dataset basedon CNN. The proposed training patterns for AE are as follows:(1) the first case the autoencoder is trained by class 0 as normal andother classes as anomalous, (2) the second case the classes 0 and 1
will be normal and other classes are reversed. Consequently, thenumber of normal classes will increase for each next case. Finallythe autoencoder will be trained with all classes as normal for thelast case. Final step of the algorithm is to evaluate the performance

O. Al aama and H. Tamukoh / Journal of Robotics, Networking and Artificial Life 7(1) 35–40

37

Table 1 | The number of images depending on training and testing
patterns

NormallabelsFigure 4 | Inversing the anomalous image.

0
0 and 1
0–2
0–3
0–4
0–5
0–6
0–7
0–8
0–9

The number of images
depending on training
patterns

The number of images
depending on test patterns

NormalAnomalous

NormalAnomalous

5000
10,00015,00020,00025,00030,00035,00040,00045,00050,00045,00040,00035,00030,00025,00020,00015,00010,000
5000
0

1000
2000
3000
4000
5000
6000
7000
8000
9000
10,000

9000
8000
7000
6000
5000
4000
3000
2000
1000
0

3.3. Evaluation of Performance
for Autoencoder
For significance validation, both F- and Z-test were conducted.
The Z-score value can be calculated based on the following
formula (10) [12]:Z=
Figure 5 | Structure of convolutional neural network autoencoder.

of the AE using an inference dataset. Figure 5 illustrates the structure of CNN-autoencoder. As shown in the figure, the input image
with size 32 × 32 × 3 is firstly convoluted in the first layer by a
5 × 5 filter.
Consequently, the image dimensions are reduced through a pooling layer from size 5 × 5 × 32 × 3 to size 16 × 16 × 32. Next, anotherconvolution layer is applied followed by a pooling layer to change
the size of the image from 5 × 5 × 16 × 32 to 8 × 8 × 16. Finally,
the encoding process is finalized with a fully connected layer
with the output size of 1 × 262144 (1024 × 256). In order to decode
the image, the reverse of the previous process is applied and finallya reconstructed image with the same dimensions as the input imageis the same as the output.

3.2. Cifar-10 Dataset
The CIFAR-10 dataset is a set of images that can be used to teacha computer how to recognize objects, it contains RGB images with32 × 32 pixels’ size. It has 10 classes and each class contains a different type of images. The dataset divides into a 50,000 images
training set and 10,000 images testing set. Each set has an equal
distribution of elements from each one of the 10 classes [11], asshown in Table 1.

x1 - x2

s 12 s 22 
+
n1 n2

(10)

where (x1 , x2 ) are the average of the input and output pixels values
respectively, (s1, s2) are the standard deviation for the input andoutput values respectively, (n1, n2) are the sample size of the input
and output respectively.
A p-value is used in hypothesis testing to help accepting or reject
the null hypothesis. It is evidence against a null hypothesis. The
smaller the p-value, the stronger the evidence that you should reject
the null hypothesis.
The used hypothesizes are; if p-value >0.05, then there is no significant difference between the input and reconstructed image (i.e.
considered as Normal).
If p-value <0.05, then there is significant difference between the
input and reconstructed image (i.e. considered as Anomaly).

4. RESULTS AND DISCUSSION
4.1. Training and Testing Loss
The difference between the test data input images and the reconstructed images were calculated in each epoch. The relationshipbetween the testing loss and the epochs is shown in Figure 6. It is worth
mentioning that the value of the test loss is almost similar or close totrain loss value and this indicates to a good reconstruction process.

O. Al aama and H. Tamukoh / Journal of Robotics, Networking and Artificial Life 7(1) 35–40

38

Table 3 | p-value for classes 0–7 as normal and classes 8 and 9 asanomalous hypothesis for HSV, RGB and TUVaClasses
0
1
2
3
4
5
6
7
8
9

b

Figure 6 | Training and testing loss against epochs for HSV color model,(a) training loss, (b) testing loss.
Table 2 | p-value for class 0 as normal and classes 1–9 as anomalous
hypothesis for HSV, RGB and TUVClasses
0
1
2
3
4
5
6
7
8
9

Color model type
HSV

RGB

TUV

0.58190.00570.00000.00760.00000.00050.00530.02130.0166
0.02670.20130.02980.01000.00080.02220.01820.03220.01780.04240.03230.29410.00120.00840.01420.00100.01090.01030.04780.00000.03774.2. Z-test
The p-value of each color model was calculated at zero mean value
for each class and the results were shown in Tables 2–4 for the threecases; in the first one only class 0 is normal while the rest are anomaly, in the second case classes 0–7 are normal and other classes areanomaly, and in the last one all classes are normal. From Table 2,
it is clear that HSV in class 0 is better than RGB and TUV as thep-value is 0.5819 which is larger than 0.2013 and 0.2941. This isbecause in the normal class the difference between input and output
image should be small as proven by p-value result. In contrast, mostof p-values of anomaly classes in RGB and TUV are bigger thanin HSV which denotes the HSV detects the anomaly classes more
effectively than other color models. Similarly, Tables 3 and 4 show
that, generally, HSV in all classes is better than RGB and TUV as
the detection in HSV is more achievable than other models.

4.3. F-test
An anomaly detection performance is usually evaluating byusing the F-test using the recall and precision as shown inEquation (11) [14]. Accomplishing high recall and high precision

Color model type
HSV

RGB

TUV

0.94730.72230.98470.07600.45450.56750.08820.42400.00410.00120.77420.19200.17950.68360.16880.93660.42780.29640.00000.00030.12960.65060.31490.1061
0.52280.16990.86370.27850.00000.0000

Table 4 | p-value for classes 0–9 as normal hypothesis for HSV, RGB
and TUV color models
Classes
0
1
2
3
4
5
6
7
8
9

Color model type
HSV

RGB

TUV

0.44400.84050.65340.72560.31550.52900.81000.17320.57560.80390.18990.68380.72210.84800.16850.15290.54890.47310.35570.88490.12620.1086
0.06530.08530.06450.0792
0.06350.44570.25700.0792

is not easy at the same time because the recall and precision goals
are often conflicting.
æ Precision ´ Recall ö
F =2´ç
(11)÷è Precision + Recall ø 
where Precision = True positives/(True positives + False positives),
and Recall = True positives/(True positives + False positives).
Figure 7 shows the F-test against the threshold for HSV, RGB andTUV respectively. The first mean point in comparing with the previous work is the horizontal range for the F-test. This range in the
proposed method was small, therefore, the correct threshold for thedetection could be defined easily. The second point is that F-value
in the previous work was bigger in case of RGB than the value inour proposed method and that indicates increasing in the accuracy.
In proposed method, the F-test for HSV color model is better thanother models.
Table 5 represents the comparison between our results and theprevious results, the proposed CNN-autoencoder has been trainedwith three different color models HSV, RGB and TUV, whereas thestacked autoencoder trained with one color model which is RGB.
Besides, the reconstruction quality results using the proposed
CNN-autoencoder for the same color model (RGB) were better
than the reconstruction results using the stacked autoencoder inspite of using the same dataset for the evaluation process.

O. Al aama and H. Tamukoh / Journal of Robotics, Networking and Artificial Life 7(1) 35–40

39

CONFLICTS OF INTERESTa

The authors declare they have no conflicts of interest.

ACKNOWLEDGMENT
This research was supported by JSPS KAKENHI Grant Numbers
17K20010.
b

REFERENCES

c

Figure 7 | (a) F-test for RGB, (b) F-test for HSV, (c) F-test for TUV.

Table 5 | General comparison between previous and proposed methods
Previous
method [13]ProposedmethodTraining color model

RGB

Structure
DatasetReconstruction
quality

Stacked AE
Cifar-10
Moderate
NA
NA
Good
NA
NA
NA
NA
NA

RGB, HSV andTUV
CNN-AE
Cifar-10
Good
Good
Moderate
Moderate
Good
Moderate
ModerateGood
low

F-testZ-test

• RGB
• HSV
• TUV
• RGB
• HSV
• TUV
• RGB
• HSV
• TUV

5. CONCLUSION
This research investigates the anomaly detection using CNNautoencoder trained with three different color models. The trained
AE has reconstructed the correct input normally, whereas theanomalous input has been reconstructed reversely. The results at
200 epochs training show that HSV color model has been more
effective in anomaly detection rather than other models based on
Z- and F-test analyses.

[1] A. Kaplan, M. Haenlein, Siri, Siri, in my hand: Who’s the fairest in
the land? On the interpretations, illustrations, and implications ofartificial intelligence, Business Horizons 62 (2019), 15–25.
[2] O.I. Abiodun, A. Jantan, A.E. Omolara, K.V. Dada, N.A.
Mohamed, H. Arshad, State-of-the-art in artificial neural network applications: a survey, Heliyon 4 (2018), e00938.
[3] W. Liu, Z. Wang, X. Liu, N. Zeng, Y. Liu, F.E. Alsaadi, A surveyof deep neural network architectures and their applications,
Neurocomputing 234 (2017), 11–26.
[4] M. Yousefi-Azar, V. Varadharajan, L. Hamey, U. Tupakula,
Autoencoder-based feature learning for cyber security applications, 2017 International Joint Conference on Neural Networks(IJCNN), IEEE, Anchorage, AK, USA, 2017, pp. 3854–3861.
[5] C. Zhou, R.C. Paffenroth, Anomaly detection with robust
deep autoencoders, Proceedings of the 23rd ACM SIGKDDInternational Conference on Knowledge Discovery and Data
Mining, ACM, Halifax, NS, Canada, 2017, pp. 665–674.
[6] P. Fonseca, J. Mendoza, J. Wainer, J. Ferrer, J. Pinto,
J. Guerrero, et al., Automatic breast density classification using
a convolutional neural network architecture search procedure,
Proceedings of the Medical Imaging 2015: Computer-Aided
Diagnosis, Orlando, FL, USA, 2015, p. 941428.
[7] Y. Sun, X. Wang, X. Tang, Deep learning face representation frompredicting 10,000 classes, 2014 IEEE Conference on Computer
Vision and Pattern Recognition, IEEE, Columbus, OH, USA,2014, pp. 1891–1898.
[8] P. Vincent, H. Larochelle, Y. Bengio, P.A. Manzagol, Extracting
and composing robust features with denoising autoencoders,
Proceedings of the 25th International Conference on Machinelearning (ICML), ACM, Helsinki, Finland, 2008, pp. 1096–1103.
[9] V. Chandola, A. Banerjee, V. Kumar, Anomaly detection: a survey,
ACM Comput. Surveys 41 (2009), 15.
[10] L. Feng, L. Xiaoyu, C. Yi, An efficient detection method for rarecolored capsule based on RGB and HSV color space, 2014 IEEE
International Conference on Granular Computing (GrC), IEEE,
Noboribetsu, Japan, 2014, pp. 175–178.
[11] A. Torralba, R. Fergus, W.T. Freeman, 80 million tiny images: alarge data set for nonparametric object and scene recognition,
IEEE Trans. Pattern Anal. Mach. Intell. 30 (2008), 1958–1970.
[12] Website: https://statmagic.info/Content/Help-Content/two-sampleprop.html (accessed July 29, 2019).
[13] A. Suzuki, H. Tamukoh, Reverse reconstruction of anomaly input
using autoencoders, 2018 International Symposium on Intelligent
Signal Processing and Communication Systems (ISPACS), IEEE,
Ishigaki, Okinawa, Japan, 2018, pp. 431–435.
[14] M. Sokolova, N. Japkowicz, S. Szpakowicz, Beyond accuracy, F-scoreand ROC: a family of discriminant measures for performance
evaluation, in: A. Sattar, B. Kang (Eds.), Advances in Artificial
Intelligence (AI), Springer, Berlin, Heidelberg, 2006, pp. 1015–1021.

O. Al aama and H. Tamukoh / Journal of Robotics, Networking and Artificial Life 7(1) 35–40

40

AUTHORS INTRODUCTION
Mr. Obada Al aama
He graduated from Al-Baath University
Department of Communication andElectronics Engineering, Syria, in 2013.
He received Master of Engineering degreefrom Kyushu Institute of Technology, Japan,
in 2019. His research interests include
image processing, deep learning and neuralnetworks.

Associate Prof. Hakaru Tamukoh
He received the B.Eng. degree from Miyazaki
University, Japan, in 2001. He received theM.Eng. and the PhD degree from Kyushu
Institute of Technology, Japan, in 2003 and2006, respectively. He was a postdoctoral
research fellow of 21st century center of
excellent program at Kyushu Institute ofTechnology, from April 2006 to September
2007. He was an Assistant Professor of Tokyo University ofAgriculture and Technology, from October 2007 to January
2013. He is currently an Associate Professor in the Graduate
School of Life Science and System Engineering, Kyushu Instituteof Technology, Japan. His research interest includes hardware/
software complex system, digital hardware design, neuralnetworks, soft-computing and home service robots. He is amember of IEICE, SOFT, JNNS, IEEE, JSAI and RSJ.