Skip to content

droidadroit/SOM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SOM

A lenna image is compressed by vector quantization using Kohonen's Self organizing map. The image is divided into blocks of base size (say 4 x 4) and the corresponding vectors are fed to the SOM. This generates a codebook of a predetermined size which is used to generate the reconstructed image.

Getting Started

Prerequisites

  1. Anaconda for Python 2.7
  2. OpenCV for Python 2.7

Installing

  1. Anaconda for Python 2.7
    Go to the downloads page of Anaconda and select the installer for Python 2.7. Once downloaded, installing it should be a straightforward process. Anaconda has along with it most of the packages we need.

  2. OpenCV for Python 2.7
    This page explains it quite well.

Running

Before running SOM.py, a few parameters are to be set.

image_location
bits_per_codevector
block_width
block_height
epochs
initial_learning_rate

image_location is set to the relative location of the image from the current directory.
bits_per_codevector is set based on the size of the codebook you desire. For e.g., for a 256-vector codebook, this value should be 8 as 2^8 = 256.
block_width and block_height are set to the size of the blocks the image is divided into. Make sure the blocks cover the the entire image.
epochs is the number of epochs this algorithm is to be run.
initial_learning_rate is the learning rate at t = 0.

Once the parameters are decided, enter the following command to run the script.
python [name of the script] [image_location] [bits_per_codevector] [block_width] [block_height] [epochs] [initial_learning_rate]

Please read the wiki for an understanding of the above terms.

Results

For the image compressed using SOM.py, click here.
The following parameters are used.

block_width = 4
block_height = 4
epochs = 3
initial_learning_rate = 0.7

bits_per_codevector ranged from 1 to 10.

Releases

No releases published

Packages

No packages published

Languages