Professional Documents
Culture Documents
Self-Organizing Map-Based Quantization Error From Images
Self-Organizing Map-Based Quantization Error From Images
1 Introduction
Self-Organizing Map (SOM) is an unsupervised machine learning algorithm
(Kohonen, 1981) that is commonly used for pattern analysis in data. Given
some input data vector, SOM organises it in related categories based on
similarity and original location of each vector.
The difference between the data and SOM’s final weights is known as
the Quantization Error (QE).
This code (in Python programming language) demonstrates the deter-
mination of the QE values for images based on a trained SOM, hereafter
referred to as SOM-QE. On exploring the functional properties of SOM-QE
value on sets of image series, it is found to be a good detector of changes
between images, (Wandeto, Nyongesa, Rémond, & Dresp-Langley, 2017).
2 The code
from pylab import imread
from numpy import reshape
import time
from minisom import MiniSom
"""
see https://github.com/JustGlowing/minisom/blob/master/Readme.md
1
on more, including instructions on how to install the it.
"""
start_time = time.time() # capture the starting time
"""
re-structure the input data to be usable by SOM.
The input will be a 3D vector to cater for the RGB values per pixel"""
input_image = reshape(image,(image.shape[0]*image.shape[1],3))
"""
Using the trained SOM, determine the quantization error of each
image in the image series
"""
print ‘.... QE for the training image’
print som.quantization_error(input_image)
# .. For the subsequent images, read an image, restructure it and find its QE
2
im1 = imread(‘first.jpg’)
im1 = reshape(im1,(im1.shape[0]*im1.shape[1],3))
print som.quantization_error(im1)
print ‘The end’
3 References:
Kohonen, T. (1981). Automatic formation of topological maps of patterns
in a self-organizing system. In 2nd Scand. Conf. on Image Analysis (pp.
214–220). Espoo, Finland.
Wandeto, J. M., Nyongesa, H., Rémond, Y., & Dresp-Langley, B. (2017).
Detection of small changes in medical and random-dot images compar-
ing self-organizing map performance to human detection. Informatics in
Medicine Unlocked, 7, 39–45. https://doi.org/10.1016/j.imu.2017.03.001