Friday, November 30, 2012

Gabor Filters, some useful links for overview

I had to go through the functionality of gabor filter for a group discussion. It was really interesting and engaging discussion where everyone really got involved, and I learned more than I taught :)..

Well, I am putting down the links I referred for my study,

http://en.wikipedia.org/wiki/Gabor_filter
http://upload.wikimedia.org/wikipedia/commons/b/b5/Gabor-ocr.png
http://matlabserver.cs.rug.nl/edgedetectionweb/web/edgedetection_params.html
https://ccrma.stanford.edu/~jos/sasp/Dyadic_Filter_Banks.htmlhttp://www.cs.utah.edu/~arul/report/node13.html

I also found a beautiful presentation about Gabor filters and texture segmentation (The most important application of Gabor filters). Here it is...

 vplab.iitm.ac.in/courses/CV_DIP/PDF/Lect-Gabor_filt.pdf

There is a matlab implementation also available :
http://www.mathworks.in/matlabcentral/fileexchange/5237-2d-gabor-filterver123
 
Enjoy!

Tuesday, November 27, 2012

compressing in Linux : the 'tar' command

I find  the 'tar' command very useful for my work especially when I work with lots of files and maintain lot of versions of code. The man page of tar is huge and I am sure there are many more flavours to it. However, I always find it confusing...there are certain customizations of 'tar' that come handy to me often and here they are...

$tar -cvzf filesDir.tgz  filesDir/
Compress all files in directory filesDir to filesDir.tgz

Suppose, you edit only a few files of a huge directory with lots of sub-folders, then you would want to save only those few files.

In such case you should maintain a fileList which contains all filenames with relative path to the parent folder.

$cat fileList.txt
file1
file2
subdir1/subdir2/file3
subdir3/file4
subdir4/


$tar -cvzf filesDir.tgz -T fileList.txt
This will compress  the files mentioned in fileList.txt. Note that subdir4/ is an entire folder. In this case, we are compressing all files contained in subdir4/

Now, comes the uncomressing part.

Go to the required path.
$ mkdir filesDir
$cd filesDir
filesDir]$ tar -xvzf filesDir.tgz


In case when you want to merge this data into another version of the same library/code, you can go into that directory and simply untar as above. The corresponding files in respective paths will get replaced by the files in filesDir.tgz, and new files and folders will be added.


Before untarring, we may want to check the difference to make sure that we are doing the right thing.


Here are the commands:
$diff -r dir1/ dir2/
This will display all the differences in two directories and their contents recursively (-r).


If you want to just see the files which correspond to changes, not the contents, then
$diff --brief -r dir1/ dir2/

Saturday, November 24, 2012

beautiful Matlab tutorials for advance usage

Found  an excellelent tutorial on Matlab for advance usage such as speed-up, debugging, using OOP.  Its been really useful to me, hope anyone who finds it will be equally delighted having found it :)

YAGTOM: Yet Another Guide TO Matlab

Enjoy!

Monday, November 19, 2012

UGM Library for Undirected Graphical Models

I was in search for  suitable library for CRF implementation for my segmentation work and found the UGM library useful, since it has some demos and nice explanations for different functionalities. It also seems to be up-to-date with different inference techniques.

Here is the link for the directory:
http://www.di.ens.fr/~mschmidt/Software/UGM.html

They have clearly explained the download and setup process. However, I found that bit scattered across different pages, so here are the steps that I went through:

1. Download the tgz from the homepage .
The 2011 version is available in www.di.ens.fr/~mschmidt/Software/UGM_2011.zip

2. There are also some updates in 2012. Download them as well.

3.Download the mex-wrapper for maxflow from the link http://www.mathworks.com/matlabcentral/fileexchange/21310-maxflow and place it under the directory UGM/

4.Download maxflow-v3.01.zip from  http://vision.csd.uwo.ca/code/ and place it inside UGM/maxflow/  under the name maxflow-v.3.0 (since the different files refer to it in the same name.)  Note: there is a  Readme.txt in UGM/maxflow/ to guide us too.

5.In matlab command window,
 >> cd UGM/
 >> addpath(genpath(pwd))
>> mex -setup
>> mexAll

In case you find errors like the following while running mexAll, sort it out using help from the other blogpost :  matlab-error-of-type-usrbinld

: /usr/bin/ld: matlab/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.10' not found (required by /usr/bin/ld) 

 

 5. >> cd maxflow/
      >> make
     >> test1 
     >> test2   % to test the functionality
      >> cd ..

In case you are in a 64-bit system, you will face an error like this:

>> make     
>> test1

??? Error using ==> maxflowmex
Function "mxGetIr_700" is obsolete in file "compat32.cpp", line 282.
(64-bit mex files using sparse matrices must be rebuilt with the "-largeArrayDims" option.  See the R2006b release notes for
more details.)


Error in ==> maxflow at 35
[flow,labels] = maxflowmex(A,T);

Error in ==> test1 at 32
[flow,labels] = maxflow(A,T)


The solution is, 

edit the file maxflow/make.m as follows:


mex -O -largeArrayDims maxflowmex.cpp maxflow-v3.0/graph.cpp maxflow-v3.0/maxflow.cpp


Then
>> make
>> test1 
>> test2   % to test the functionality
>> cd ..


6.  Run any demo present in UGM/examples/. For example,
  >> example_UGM_AlphaBeta 

Friday, November 9, 2012

Handling Sparse matrices in Matlab

Matlab has its own memory limits due to which we have to define very large matrices
as sparse and use them. But we can not use them exactly the same way as normal matrice
due to difference in the way of storage. In my case, I have to define neighborhodd of 
pixels in an image which is usually of large size(307200 for a 640x480 image!!!). So,
the nbrhood matrix (lets call it adj) is now of size 307200x307200, which is huge.
 
I posted this in stackoverflow and had a beautiful discussion over the forum.
  
>>nNodes = 50400;
 
>>adj = sparse(nNodes,nNodes); %adj is a large sparse matrix with all values as zero.
 
I want to insert a 1 to adj(i,j) if pixel i and j are adjacent.
 
>>adj(sub2ind([nNodes nNodes], ind, ind + 1)) = 1; %ind is a vector of indices
??? Maximum variable size allowed by the program is exceeded.
 
Therefore, it is better to define adj in the following way, where definition
and updation take place in one shot. 
 
>>adj = sparse(ind, ind + 1, ones(size(ind)), nNodes, nNodes, length(ind));
 
Now, how do we access sparse matrix elements?
 
In a general matrix, we can access and modify the elements, 
either by using 2-dimensional indexing  or linear indexing.
 
for example,
 
>> a = [ 1 2 3; 4 5 6]
a =
     1     2     3
     4     5     6

>> a(1,2)
ans =
     2

>> a(3)
ans =
     2

 
Similarly,
>> i = find(a == 2)
i =
     3
>> [i,j] = find(a == 2)
i =
     1
j =
     2

But we do not have the luxury to access using linear index 
for sparse matrices.
 
If I want to access non-zero elements of sparse matrix, I have to 
access the following way:
 
>> [i,j] = find(adj); 

The elements with higher indices must be accessed with 
2-dimensional indexing:

>> adj(nNodes, nNodes)
ans =
     0

>> adj(nNodes * nNodes)
??? Maximum variable size allowed by the program is exceeded.
 
That's it with sparse matrices for the time being. :)
 

Monday, November 5, 2012

Video Lectures of BMVC 2012

The video lectures of tutorials, keynote speeches and oral presentations BMVC 2012 are available in  the following link:

http://videolectures.net/bmvc2012_surrey/

They seem to be interesting, so I decided to listen to them :)

I am going to list down the ones interesting to me as I listen to the lectures one by one ...

1. Pushmeet Kohli's talk on MRFs: http://videolectures.net/bmvc2012_kohli_discrete_models/



Sunday, November 4, 2012

Matlab error of the type : /usr/bin/ld: matlab/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.10' not found (required by /usr/bin/ld)

When I tried to compile mex files in Matlab (R2009a, 32-bit) on my Ubuntu 11.10 system, I got the following error:

>>mexAll

/usr/bin/ld: /home/swagatika/softwares/matlab/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.10' not found (required by /usr/bin/ld)
/usr/bin/ld: /home/swagatika/softwares/matlab/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/bin/ld)
/usr/bin/ld: /home/swagatika/softwares/matlab/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/bin/ld)
collect2: ld returned 1 exit status

    mex: link of ' "minFunc_2009/lbfgsC.mexglx"' failed.


Well, I found that I upgraded my system from v10.10 to 11.10. In the process, the libraries stored in Matlab were not updated with the system libraries.

So when such an error occurs,

1) Locate the library file in the system.
2)Remove or create a back up of the library in Matlab path.
3)Create a soft link in the matlab's appropriate folder for the one present in /usr/lib/

$ locate libstdc++.so.6
/home/swagatika/.dropbox-dist/libstdc++.so.6
/home/swagatika/softwares/matlab/sys/os/glnx86/libstdc++.so.6
/home/swagatika/softwares/matlab/sys/os/glnx86/libstdc++.so.6.0.9
/home/swagatika/softwares/matlab/toolbox/shared/hdllink/scripts/linux32/libstdc++.so.6
/home/swagatika/softwares/matlab/toolbox/shared/hdllink/scripts/linux32/libstdc++.so.6.0.9
/home/swagatika/softwares/matlab/toolbox/symbolic/mupad/linux/lib/gcclibs/libstdc++.so.6
/usr/lib/i386-linux-gnu/libstdc++.so.6
/usr/lib/i386-linux-gnu/libstdc++.so.6.0.16
/usr/lib/ure/lib/libstdc++.so.6


$ln -s /usr/lib/i386-linux-gnu/libstdc++.so.6 libstdc++.so.6

Now it compiles properly.

Thursday, November 1, 2012

IROS 2012 Videos

I found the following link from a friend, the videos are awesome to watch. Each of them is very interesting. So here is the link to motivate us :)

http://spectrum.ieee.org/automaton/robotics/robotics-hardware/iros-2012-video-friday#.UHg0VVEtI9Y.facebook