Sunday, February 5, 2012

Intro to vision - Images and representation

I am dabbling in computer vision and it helps if I can gather my thoughts. (This field is not as simple as I imagined it to be.) There are a lot of background and information which goes missing , and I hate reading the unabridged versions of text. So, here goes:

Vision is primarily concerned with images, video can be treated as a series of images at a certain rate or frequency. There is the 2-D and 3-D representation of images. I shall not talk about 3-D since my knowledge on that is limited at best.

What does 2-D representation mean? Backtracking a little, every image is represented by a series of pixels, these pixels store some information. In a 2-D representation, the pixels are spread across 2 dimensions, lets say X and Y (for convenience). This is generally represented in matrix form, where the top-left pixel of the image is the top-left value in the matrix.

What are these pixel thingies? These "pixels" can hold different types of information. One common type in vision is the RGB space, where we represent the color space of the image with the composites of red, blue and green. Each of these are called the channels of the color space. Ideally, we use 8 bits for each color, thereby 2^8 = 255 possible values for each component. You can also represent the image using 18-bit color, 32-bit color and 48-bit color. These various color spaces correspond to different color depths. TrueColor is the 24-bit color, with each channel RGB getting 8 bits.

There are also CMYK, sRGB, scRGB color spaces which are used in HDR (photo enthusiasts alert), but vision folks generally deal with RGB or BGR(reverse RGB representation) color spaces.

For more on the color representation look here and dig up more - http://en.wikipedia.org/wiki/Color_depth

Although this color representation is great it does not give us an intuitive idea of color. If for example I want orange, its R=255,G=142,B=13. If I want a darker orange its R=210,G=65,B=0. So, it becomes hard to play with these colors and we use the HSI (Hue, Saturation and Intensity model). This is seen in displays and color pickers across the digital image applications. We can easily get a darker or lighter color by varying the saturation making our lives much easier.

It is possible to convert from one space to another, and most libraries have api's for easy conversion.

So, if we see a image, we can imagine it as a matrix containing 24bits in each matrix cell to represent a pixel on the image.

Saturday, January 21, 2012

Mobius Strip

The mobius strip is a wonderful geometric conundrum. It perplexes you since it is a closed 3-D object with only one edge (lo and behold!). It is really easy to make one of these, take a piece of paper and twist it clockwise on one edge, counter clockwise on the other edge join the two edges and you have this quizzical geometry.

This image describes it correctly:


Why am I putting this here? Well, I have this annoying habit of setting wires and straps on bags straight. I recently ran into this mobius strip on a bag, seeing that I could not make it straight made me wince. I could not come up with a name to attach and put my frustration on. Now I can. :)

Monday, September 26, 2011

matplotlib thou art not matlab

I am a little taken aback by the matplotlib apis, their examples don't seem that clear on data visualization. Being a former matlab user, I switched to matplotlib as it gives me access to both nltk, opencv, numpy/scipy. But in hindsight, I could just use the insane matlab toolboxes for these purposes and be done with it.

Saturday, June 25, 2011

Shogun toolkit

A fellow researcher (read arun) in semantic parsing and sentiment analysis directed me towards the shogun toolbox. Amazing features; it implements a range of weighted kernels, SVM and HMMs. It has interfaces to python, matlab and R (in my order of preference). It also supports ascii, Json and xml data formats. The best part is its got about 600 examples (albeit not in pydoc and for dna data!!!); a few I read took me about 5 mins to understand. (5 mins, now to get someone more brilliant to explain everything else I need, R2-D2, scooby-doo)

So now if I am rapid prototyping some algorithm I can do a instant analysis for many SVM methods and also HMM classification in very little time. Now maybe I can prove my algorithms are seriously inefficient and need lots of work or they can kick ass with the best of methods. (I am rooting for the latter)

I know PyML is slow and trying to catch up, but if only they just used everything form shogun and wrote new wrappers in PyML form and their fantastic doc. (I do wish a lot!!)

Time to fire the infinite improb drive and head to my bed.

Tuesday, June 14, 2011

Woes in data representation

I have been dabbling with numpy for a while, creating serialized objects and memory mapped files. The numpy package is great because it give s you the flexibility of using python, it is definitely not as fast as implementing the same in C, but you so have the alternative to use Cython (well if you do care).

I have written a converter for the date object, I was trying to look at time series analysis, but turns out if I am using a converter I need to return in float or string and cannot store in date object format. What a bummer!!

I don't have an idea how to use serialized objects or the parallel in matlab, the next quest learn the magical techniques in matlab.

Wednesday, December 1, 2010

Discovering order in chaos and learning to control it

A course I have taken this semester has lent my imagination a new kick-start. When you learn about Karl Sims' creatures, Hod Lipson's data extraction, Turing's reaction diffusion models and Neumann's self replicator, you are dumb founded, inspired, amazed.

To this day I believe in my skills as an observer and experimenter, but when I read about Neumann and his penchant to visualize processes, trace phenomena correctly without any knowledge I am left speechless. Turing's quirkiness was particularly well known, but his thought about finding patterns through morphogenesis and obviously the Turing machine. The present day researchers are not too far behind, Lipson's work seems interesting and very promising.

Now that I have all that out of my system, let me talk about these few guys from the max planck institute who have aroused my curiosity and beckoned my imagination to sit and ponder of the what-ifs and could-bes. This  bunch of people who have been featured in nature - http://www.nature.com/nphys/journal/v6/n3/full/nphys1508.html have observed unique neural behaviour in insects and captured it in a simple neuron model whose ground state is chaotic but is controlled by sensory inputs  to generate behaviours. These discoveries in the neural behaviour and contruction could shed light on the actual neural processes in humans leading to potentially simple and effective models of behaviour. In combination with techniques like subsumption architectures(doomed as a failure or atleast not so successful), we could look at simple and evolvable solutions to various problems in locomotion and path planning.

Going further,  if we could apply a chaotic organization mechanism to the reasoning process in AI, we would have made great advances. The reasoning scheme in AI has huge problems with representation and these problems will continue to haunt us, but some progress towards such self organizing behavior would definitely go a long way.

Thursday, November 4, 2010

Player - stage Installation

Installing the player/stage I ran into a few problems and did not find good solutions, I am posting what worked for me-


1. Download the player project
2. Extract the player folder
3. sudo apt-get install python-gdal netcdfg-dev libpq-dev libhdf4g-dev libgeos-dev libatk1.0-0 lib3ds-dev freeglut3-dev
4. Run cmake (if you want create a directory for build like the install guide specfies)
5. Run make
6. Run sudo make install
7. add the following to your .bashrc file 

export PATH=$PATH:"/usr/local/lib64"
export PLAYERPATH="/usr/local/lib":"/usr/local/lib64"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/usr/local/lib":"/usr/local/lib64"


This should get you to set up.

This link http://www.control.aau.dk/~tb/wiki/index.php/Installing_Player_and_Stage_in_Ubuntu has a lot of information for installing and configuring your player information