Saturday, 23 June 2012

No sound on Ubuntu 12.04 after upgrading from 11.10

I have recently upgraded my Ubuntu 11.10 distribution to Ubuntu 12.04 LTS on my HP pavillion dv6 laptop.

This is the output from 'aplay -l' command of my system.

card 0: Intel [HDA Intel], device 0: STAC92xx Analog [STAC92xx Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: STAC92xx Digital [STAC92xx Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

After rebooting I noticed that I had no sound. After trying many things, to resolve this problem I had to add the following two lines to the "alsa-base.conf" file.

alias snd-card-0 snd-hda-intel
options snd-hda-intel model=auto

If this does not work then replace "auto" with the following keywords one at a time. Save the file and restart your computer each time you test with one configuration.

ref                    - Reference board
mic-ref            -Reference board with power management for ports
dell-s14           -Dell laptop
hp                     -HP laptops with (inverted) mute-LED
hp-dv7-4000  -HP dv-7 4000
auto                  - BIOS setup (default)

Reference :- ubuntu 12.04 no sound vostro 3300 i5

Saturday, 21 April 2012

Lunux/Ubuntu not booting up after the kernel update?

After I have upgraded to 2.6.38-9-generic kernel I got the following message and I have tried many thing but this is how I have solved the problem.

Gave up waiting for root device. Common problems:
-Boot args (cat /proc/cmdline)
-Check rootdelay= (did the system wait long enough?)
-Check root= (did the system wait for the right device?)
-Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/disk/by-uuid/310147a9-f21c-4e7c-aeb0-18f31073da58 does not exist. Dropping to a shell!

BusyBox v1.10.2 (Ubuntu 1:1.10.2-2ubuntu7) built-in shell (ash)
Enter 'help' for a list of built-in commands.


Boot your computer and when the grub loader appears, select the linux version you use (to the rescue mode) and press 'e' to edit it.

Then remove the the UUID= part of the line from root=UUID=

Replace it with your current partition, so in my case it looks like


press +x to boot up with the changed settings

Then after you have logged in install fglrx module.

sudo apt-get install fglrx

Then restart.

Now this time select your linux version but this time not the rescue mode.

Then replace the UUID how you did earlier.


To permanently apply the settings to grub, you will have to edit the grub.cfg file

sudo vi /boot/grub/grub.cfg

Friday, 20 April 2012

Intelligent Agents in a simulated environment

The following video and the description is about a Agent simulation that I have designed and implemented. I would like to give my gratitude to the "Intelligent Agents" module director 
Dr. Sam Steel at the University Of Essex for his supervision throughout the module.

The simulation shows an "Agent-world" represented by a grid of squares. Agents survive in this world by eating plants. There are four types of plants that occur in various quantities. Agents are able to consume a combination of plants and gain more energy. The energy levels decreases as they live and as they roam to other squares in the gird. Creatures can carry a limited amount of plants so then can eat when it is needed. If the creatures can create two combinations at once then the most energetic combinations of plants will be eaten first.

In the “Agent world” there could be maximum of two types creatures in the world.

The agent types:

SimpleCreature: Less intelligent creature.

IntelCreature: Most intelligent creature.


A simple creature will be born in the agent world with a limited amount of energy. The creatures move around the world in random directions in a consecutive manner, for random amounts of times, with an intention to feed to survive. A simple creature can carry a limited amount of plants. This creature eats plants when it's energy goes down less than it's energy limit. (When it feels hungry) The creature is able to consume compounds(CP)of plants (P) of varied types (t) that they carry, and gain more energy than it would if it eats them individually. Such that:

CP = {Pt1, Pt2, Pt3, Pt4}

Creatures can only see the plants in the same square as it is. When the world has been resized, eventually the creatures will follow back in to the world. Each individual creature has got a unique ID. This phenomenon has been recorded on the video.

The simulated environment in which the creatures act:
The “Agent world” is a grid of squares. The plants and the creatures will be in this grid.


Only an IntelCreature can look around. These creatures can only see only one square around ahead, as well as the square it is interpolated. They can also see the the plants as well as the creatures in its range of vision.

The creature can remember the creatures and the plants in the squares that it can see (This memory is limited). Although the vision is perfectly accurate only within its local square. Just after it has been born, IntelCreature will be in an Observation mode, so that it will observe the world by capriciously observing the world until it finds more than one plant. Then it will start going after the plants intentionally that it sees around. A creature may decide to go after plants that are more therapeutic than the others. Such plants may be the plants that could complete a combination.

If two creatures meet together in one square they start talking to each other, asking about the plants that the other creature carry. Then the first creature will propose to the other creature for a shared combination, with the amount that it would like to share. Such that:

combo1 = P1 + P2 + P2
Ag1:Plants = {P1, P3, P3, P1}
Ag2:Plants = {P2, P2, P3}


Ag1: Ag2.requestCombo(<share_amount>, <plant>)

If the other creature agrees then they will consume the plants and share the energy amount. When they share the plant combinations, they will get the double the amount of the normal combination, hence it is more desirable for the creatures to share. The creatures can decide to be partners with another one, and go for other plants that one of the creatures have seen. Furthermore when the creatures are in the same square, they may request other creatures to be parters, a creature will request to be a partner of another creature, if the plant the second creature is going after, interests the first creature. If the second creature agrees to be partners, then it will make a leader and partner relationship between each other. The first creature that made the request will be the partner and the other will be the leader.  After the leader gets the plant, the energy amount will be shared. Finally the partnership will end and the two creatures will go their own ways. In the situations where the plants that are subject to the partners engrossment have been taken by some other creature, the partnership will immediately end. When the partnership has been made, the colour of the red circle, will change to a light yellow colour if it is a partner, and the colour of the leader's circle will change in to dark yellow. This is demonstrated in the figure blow.

A creature can make partnership with another one, only if the both of the creatures are neither a partner or a leader. If the creatures do not carry any plants and it can not remember any plants, it goes back to the Observation mode to collect information about the world(Grid). If the creature can not carry any more plants, it will stop travelling to save the amount of energy that it will loose by going to other squares.

What are plants?:
  • There are four types of plants in the world.
  • Green plants, Red plants, Yellow plants, and Magenta plants.
  • The plants are represented in small squares with the colour of their names.
  • Each plant holds different energy levels.
  • A plant set consists of a set of random types of plants.
  • The plant sets appears in the “Agent world” in arbitrary places.
  • The amount of the plants that will be put in to the grid is variable. 
  • In the world there will be a constant amount of plants at a time.
  • The size of the “Agent world” is variable.
  • The number of types of plants are in the world are variable.
  • The energy of creatures will be consumed until it dies. The energy consumption speed is variable.
  • If the creature moves to a different square, more energy will be consumed than if it stays in the same square.
The log output of the software which show
  • what a particular simple creature does
  • what a particular creature that looks around does
  • the interaction of a two creatures who meet 

The above description about the "AgentWorld" is just a brief introduction about the project. Accordingly there are many other theoretical and technical details that I have not introduced to you in this article. Although if you are interested, I am happy to supply you with further details on this project.

Wednesday, 18 April 2012

Bicycle Actuators Artist Edition playing cards

The new arrival to my playing card collection. Bicycle Actuators Artist Edition deck has been designed by Lance T. Miller. This is a great piece of art work that was hand drawn by the designer. Only 2500 decks have been printed and all of the decks have been individually numbered.

For more information follow the link to the kickstarter project.

Lance was grateful enough to sign my deck :)


Wednesday, 4 April 2012

Content Based Image Retrieval using cross correlation co-efficiency

Have you ever searched google for images? I am sure everyone who is reading this article has done this before more than once. Wouldn't it be nice if you could search images for the similar images, for a given image? So for an example, if you want to search for an image of a particular object, by supplying a probe image (a image which to find similar images of) to the search engine, you can search for images that are similar to the given image.

Content-based image retrieval (CBIR) or Query by image content (QBIC), is an active area in Computer Vision research. Comparing images using cross-correlation efficiency was similar to the state of the art for CBIR in the early 1990s. Comparing the colours in the probe image and other test images, is one conservative way of doing this. Histogram is a good way of discriminating the colours in an image.

One way of doing this is explained below. There are many ways of doing this although this is not necessarily the right or the best way of doing it.

  1. Split the R,G,B channels of the probe image
  2. Split the R,G,B channels of the "test image" that is subject to comparison.
  3. Calculate the histograms of the R,G,B channels of each images.
  4. Calculate the cross correlation of the R, G, B channels of the probe image and the "test image" histograms. Such that, 
    r1 = correlation(img1.R,img2.R);
    r2 = correlation(img1.G,img2.G);
    r3 = correlation(img1.B,img2.B);

     5. Finally multiply the results all together ( r1 x r2 x r3 )

The result (r) of a cross correlation calculation lies between -1 and +1. If the value is +1 in average the two images are identical. If it is -1 then the images are identical but the image looks like a photographic negative version of the probe image. If r=0 then the images are on average very unlike each other.

People who are interested in Computer Vision are likely to be familiar with the OpenCV library. The following code snippet (incomplete) is an example for calculating the cross correlation co-efficiency using the OpenCV library in C.

  //split img1 in to RGB channels and store them in seperate images

  cvSplit(img1, img1R, img1G, img1B, NULL);


  //calculate histograms of the the image

  CvHistogram *h1R = calHistogram(img1R, bins, ranges);

  CvHistogram *h1G = calHistogram(img1G, bins, ranges);

  CvHistogram *h1B = calHistogram(img1B, bins, ranges);

    //split the image two in to RGB channels and store them

    //in seperate images

    cvSplit(img2, img2B, img2G, img2R,0);


    //calculate histograms of the RGB channel images of the "img2"

    CvHistogram *h2R = calHistogram(img2R, bins, ranges);

    CvHistogram *h2G = calHistogram(img2G, bins, ranges);

    CvHistogram *h2B = calHistogram(img2B, bins, ranges);


    //Calculate the correlation coefficient of RGB images, of img1 and img2

    rR = cvCompareHist(h1R,h2R,CV_COMP_CORREL);

    rG = cvCompareHist(h1G,h2G,CV_COMP_CORREL);

    rB = cvCompareHist(h1B,h2B,CV_COMP_CORREL);


    //Multiply the results together

    tempR= rR*rG*rB;

The performance:

Some performance evaluation has been done on this program using a test harness called 'Fact'.

Error rates calculated from mycbir
tests TP TN FP FN accuracy recall precision specificity class
8 0 0 8 0 0.00 0.00 0.00 0.00 box
8 0 0 8 0 0.00 0.00 0.00 0.00 cockeral
8 6 0 2 0 0.75 1.00 0.75 0.00 dog
9 7 0 2 0 0.78 1.00 0.78 0.00 horus
8 7 0 1 0 0.88 1.00 0.88 0.00 ornament
10 8 0 2 0 0.80 1.00 0.80 0.00 penguin
8 1 0 7 0 0.12 1.00 0.12 0.00 reindeer
9 2 0 7 0 0.22 1.00 0.22 0.00 tortoise
68 31 0 37 0 0.46 1.00 0.46 0.00 overall

TP = True Positives
TN= True Negatives
FP = False Positives
FN= False Negatives

In the matrix above it shows the amount of test cases for the each picture in the “test” column, True Positives, True Negatives, False Positives and False Negatives in the next four columns.  Then the application calculates the accuracy, recall, precision and specificity as follows, and displays in the next four columns. The last “class” column show the type of picture that it has carried out the test on,

Precision is the number of relevant pictures that are retrieved, divided by the total number of of pictures retrieved. Recall is the number of relevant pictures retrieved divided by the total existing relevant pictures. The specificity and the accuracy is calculated as below

                                      TP                                                                        TN                                    
sensitivity = recall = ------------------                                       specificity =     -----------------
                                TP + TN                                                                   FP + TN

 As you can see above, the application has failed to find the True Positives for the “box” and “cockeral” pictures. So in contrast it has found False Positives in all cases. The best case is the tests on the ornament pictures as it has found 7/8 TPs and 1/8 FPs. Overall this algorithm has done 68 test cases and have found 31 True Positives and 37 False Positives, but no True Negatives or False Negatives.
The matrix below, is the class confusion matrix.

Confusion matrix calculated from mycbir
actual box cockeral dog horus ornament penguin reindeer tortoise
box 0 0 0 0 0 0 0 1
dog 0 0 6 0 0 0 0 0
horus 0 0 1 7 0 0 0 4
ornament 1 1 0 0 7 2 7 0
penguin 1 0 0 0 1 8 0 0
reindeer 5 7 0 1 0 0 1 2
tortoise 1 0 1 1 0 0 0 2

The columns and rows indicates that, the classes in the rows titles were obtained when the classes in the column title should have been found (Rows as obtained results, columns as expected result). The numbers indicates the number of times it has been obtained. So as an example, as the worst case: in the “box” column,

ornament =1, penguin = 1, reindeer = 5, tortoise = 1 has been obtained when “box” pictures should have been found. But it has not obtained any “box” pictures as the value of the “box” raw is 0.

As I have mentioned earlier the best results has been obtained on the tests with the “ornament” picture. It has obtained the correct “ornament” pictures 7 times and a penguin picture just one time.


Cross correlation is not the best Content based Image Retrieval technique to date, though it helps us to understand how the histograms of two images can vary or can be complementary. But it is no doubt that analysing just the colours in images are a good way of characterising them though it is hard to compare two images using just this factor.