## Tuesday, 20 September 2016

## Tuesday, 2 August 2016

### Particles explained using Gifs!!

Particles, just like most existing algorithms in computer science, are inspired by nature. Have you ever seen a beam of sunlight coming through a window and illuminate a bunch of floating particles (impossible in London though I have seen it before)? When you see these tiny particles, you notice that they are suspended in air and that it's very difficult to predict their motion unless you disturb the surrounding air. This simple concept is vital for many computer algorithms that model motion/dynamics of an object.

Particles, along with their randomness, can be simulated inside a computer program. The simplest of such algorithm is called Random Walk, where a particle is modelled with its current position/state alone and a random displacement/jump determines its next position in time. Here I have shown one Random Walk particle:

A Single Random Walk Particle |

## Monday, 6 June 2016

### Expectation Maximization for Gaussian Mixture Model in OpenCV

I recently wrote code for Gaussian Mixture Model (GMM) based clustering in C++. As always, I found it much convenient to use OpenCV for manipulating matrices. Although there already exist an implementation of Expectation Maximization-based GMM, I tried to understand it by writing my own implementation.

The basic idea of GMM is to first randomly assign each sample to a cluster. This provides initial mixture model for clustering. This is then optimized using

The basic idea of GMM is to first randomly assign each sample to a cluster. This provides initial mixture model for clustering. This is then optimized using

**E**xpectation - or the probability/score of assigning each sample to each component in GMM - and**M**aximization - or updating the characteristics of each mixture component with the given probability/score . An attractive attribute of GMM is its ability to cluster data that does not have clear boundaries for clusters. This is achieved by having a probability/score for each sample from each cluster component.## Tuesday, 17 May 2016

### A Random Walk

It is fascinating to see the use of the word 'random' and its resemblance to one of the most basic ingredients in some computer algorithms. One may ask what is it that makes something random?

- "So you just made a

- "Students were

- "He figured out that he still had an hour to his departure, so he went for a

- "So you just made a

**random**deal?"- "Students were

**randomly**chosen to take part in a drama."- "He figured out that he still had an hour to his departure, so he went for a

**random**walk."## Monday, 9 May 2016

### Matlab script for checking and deleting folders

Just putting this simple but extremely useful matlab script for my future self and anyone trying to handle folders using matlab. This script checks all the sub directory within the starting directory and then deletes the one that do not satisfy a given criteria. In my case this was the number of image samples within a folder.

% script for deleting folders with less than a certain number of files close all clear all clc % count the number of png files D = dir(' '); numFoldersOrFiles = size(D, 1); thresholdFiles = 30; % skipping the first two which are just . and .. for i = 3: numFoldersOrFiles if D(i).isdir Ds = dir([D(i).name '\*.png']); numFiles = size(Ds, 1) / 3; if numFiles < thresholdFiles rmdir(D(i).name, 's'); end end end % all done :)

Labels:
code,
matlab,
Simple Tweaks,
Windows

## Saturday, 16 April 2016

### OpenCVKinect 2.0 - Acquiring Kinect depth stream in OpenCV

It has been almost two years since I first wrote the code for OpenCVKinect. It has been really good to know that it has been used by a number of other students/developers at GitHub for collecting and analysing Kinect depth streams in OpenCV. I have had some feedback about a possible bug and some students have asked how they can visualize the depth maps in a better way. So today, after a long time, I am releasing the first official update to this project.

Labels:
binaries,
c++,
code,
Computer Vision,
Kinect,
Open Source,
OpenCV,
OpenNI,
Real-time,
Windows

## Thursday, 14 April 2016

### Particle Filtering - Survival of the fittest

I recently studied dynamic system models such as Kalman and Particle Filters.

For Kalman Filter I followed a Matlab demo that can be found here.

In this demo, the simple problem of tracking a ball is addressed using a Kalman Filter. The input sequence is of a ball, which is travelling at varying velocity and which is occluded in some frames by a box. I think this is a great example to demonstrate the power of dynamic system models, especially the occluded frames can be used to test how good a dynamic model is. Here is the actual sequence:

As you can see the ball goes underneath the box and comes out of the other end. If our dynamic model is accurate it will be able to predict the state of the ball even when it is not visible, and should match the position when the ball comes out.

For Kalman Filter I followed a Matlab demo that can be found here.

In this demo, the simple problem of tracking a ball is addressed using a Kalman Filter. The input sequence is of a ball, which is travelling at varying velocity and which is occluded in some frames by a box. I think this is a great example to demonstrate the power of dynamic system models, especially the occluded frames can be used to test how good a dynamic model is. Here is the actual sequence:

As you can see the ball goes underneath the box and comes out of the other end. If our dynamic model is accurate it will be able to predict the state of the ball even when it is not visible, and should match the position when the ball comes out.

## Monday, 28 March 2016

### Designing an algorithm - from ideas to code

I had always been interested in solving sudoku puzzles, partly because there are too many combinations that make each Sudoku unique. Since my work involves writing and using programming in different scenarios, I thought why not try using my skills on Sudoku. So there I was on a London Underground train to Barbican - looking at a Sudoku puzzle at the back of a morning newspaper, wondering how I can write an algorithm to solve it. I figured out a few simple tricks that I have always used in algorithm design. Here I explain what thoughts I had while designing my very own Sudoku solver and how I transformed those ideas into a working prototype.

First of all lets have a look at a typical Sudoku puzzle and some basic rules:

Sudoku Puzzle |

Yes - it has got everything to do with numbers!! lots of numbers!

A Sudoku puzzle typically has 81 boxes where each box can have a number between 1 to 9. However, all these boxes follow some rules that make it all interesting. You may have noticed 3x3 squares grouping the number boxes. A correct solution of Sudoku ensures no repetition of numbers from 1 to 9 inside each of the 3x3 squares, in each horizontal line and each vertical line. When solving a Sudoku puzzle, this is exactly where I look for a solution, and exactly where my thought process starts for my Sudoku solver algorithm.

Labels:
algorithms,
application,
code,
demo,
matlab,
puzzle,
skill,
Tutorial

Subscribe to:
Posts (Atom)