Pattern Recognition using Nearest neighbor (NN) classifier and k-means clustering.


Nearest neighbor (NN) classifier and k-means clustering are two typical algorithms for pattern classification. In this Project, I apply these algorithms to classify the objects based on the intensities of the image shown on right.

Car with Controller
Fig.1 - Original Image.


Divided Image into 4x4 disjoint subimages. Each subimage is a 16 dimensional pattern vector. Used the pattern vectors at the upper half of the image for training and used the lower half of the image for testing.

1. Upper Image divided in 4x4 blocks
2. Average of each block is determined
3. If average is in the range of 0 – 125 then block belongs to class 1. If average is in the range of 125 - 175 then block belongs to class 2. If average is in the range of 175 - 255 then block belongs to class 3.
4. Depending on the class, block is given 0,128,255 values respectively. This resulted in generation of image I1 (Fig.2).

3. NN classification of the testing pattern:
1. Lower half of image is taken for testing.
2. The lower half of image is divided into 4x4 blocks and each 4x4 block of testing image is compared with every 4x4 block of training image.
3. By this, each 4x4 testing image block is mapped to the nearest 4x4 block in training image.
Comparison of testing blocks to training blocks is carried by:
((x1-y1)2 + (x2-y2)2 + …. (x16-y16)2)1/2 / 16
Central Server.

1. Traffic lights were replaced with a central controller that will make the cars halt or pass through critical sections without any collisions.
2. A rudimentary scheduling algorithm was designed that would batch the cars to allow maximum cars pass through the intersection point.

Car with Controller
Fig.2 - Image I1.
Car with Controller
Fig.3 - Image I2.


1. The system was tested with two path schemes namely Path Scheme A and Path Scheme B (Paths are used to mimic GPS inputs) where the route of destinations was supplied to cars and the cars had 100% success rate
2.Final aim of eliminating the dependency on traffic lights was achieved collectively because of the seamless interaction between the backend server and the cars.

Car with Controller
Car with Controller