2012 in review

January 2, 2013 Leave a comment

The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

4,329 films were submitted to the 2012 Cannes Film Festival. This blog had 23,000 views in 2012. If each view were a film, this blog would power 5 Film Festivals

Click here to see the complete report.

Advertisements
Categories: Uncategorized

Running Makefile on the Windows

August 1, 2012 Leave a comment

There are many ways to run make program on the Windows, many of them will ask you to run in cygwin or similar shells. I was interested in running the makefile in the Windows so that the application generated could be used by the other Windows programs.
So the solution is to use the Visual Studio Command Prompt, run it, cd to the directory where the makefile is and then use the following

nmake -f Makefile

If the Makefile is using g++ or gcc in it you have to change it to “cl”, this the compiler being used by the VC. You might have to make little changes but then it should work fine.

 

Have a look at following

http://stackoverflow.com/questions/2532234/how-to-run-a-makefile-in-windows

 

Categories: C++, code Tags: , , , ,

Yi Ma’s Robust Face Recognition using Sparse Representation; matlab code

June 29, 2012 3 comments

Following is a matlab version of simple Face Recognition algorithm given by Yi Ma.

</pre>
%build the dictionary from training
imgTrain = double(Tr_dataMatrix);
imgTest  = double(Tt_dataMatrix);

mx = mean(imgTrain,2);
D = imgTrain - repmat(mx, 1, size(imgTrain,2));

imgTest = imgTest - repmat(mx, 1, size(imgTest,2));

totalTest = size(imgTest,2);
lambda2 = 3;
addpath D:\mohsen\matlabCode\sparseCoding\elad\;
[U S V] = svd(D);
[egVal ind] = sort(diag(S), 'descend');
egV = U;
egV = egV(:, ind);

D = egV(:,1:200)'*D;
D = D./repmat(sqrt(sum(D.^2)),size(D,1),1);
imgTest = egV(:,1:200)'*imgTest;
 ci = zeros(size(D,2), size(imgTest,2));
ci = GetSparseFast(D,imgTest,0*zeros(size(D,2), size(imgTest,2)),500,1, 40);
testImgId = [];
rejectedI = [];
for i=1:totalTest
 recEr = 0;
 recMinid = -1;
 for p=1:totalPeople
   recErt = norm(imgTest(:,i)-D*(ci(:,i).*(imgTrainLabel'==p)));
   if recErt < recEr || p == 1
        recMinid = p; recEr = recErt;
   end
 end
 testImgId(i) = recMinid;
end

Matlab and Object orientation

March 3, 2012 Leave a comment

It’s high time to start implementing the object orientation in the matlab. If you are good in C/C++ you know how to develop classes and why to develop them.
Few caveats however, changes inside the method of any class member does not mean that object has been updated. Remember to return the object itself and re-assign it to iself. Unless you define it as subclass of ‘handle’. http://www.mathworks.com/help/techdoc/matlab_oop/brfylzt-1.html#brfylzt-2

 

When Pre-Allocating (i.e. array of classes )use the “empty”
have a look at http://www.mathworks.com/help/techdoc/matlab_oop/brd4btr.html#brd4nrh

srun and matlab

November 19, 2011 Leave a comment

ok Mr. Cluster, here I come, I have unlocked the power to issue commands to your nodes for my maltab function ha ha ha ha!

so if you are in slurm
srun -n1 -o t.txt matlab -nodesktop -nosplash -nodisplay -r “temp4(29)” &

t.txt <— will get all the output

after -r you can give all the commands as the form of script i.e. ” ”

in above case temp4 was matlab file function, and 29 was input

& so that it can run in background

-n1 only one measly node 😦

But then you can run multiple of such commands and each one gets node 🙂

Don’t forget to open the matlabpool in the file you are running if you are using the parallel commands.

Categories: basic, code, matlab Tags: , , , , ,

getPatch; matlab function to get a patch from a matrix

April 1, 2011 Leave a comment
function mat = getPatch(srcMat, rect)
%function getPatch(srcMat, rect)
%rect is [x y width height]

stX = max(rect(1),1);stY = max(rect(2),1);
endX = min(rect(1)+rect(3)-1, size(srcMat,1));endY = min(rect(2)+rect(4)-1, size(srcMat,2));
mat = srcMat(stY:endY, stX:endX);
Categories: code, matlab, matlab Code Tags: ,

cygwin/x cannot establish any listening sockets

March 10, 2011 Leave a comment

Running cygwin/x I was facing following error
Cannot establish any listening sockets  Make sure an X server isn’t already running

poked around to find what’s happening, firewall was fine and I was on the administrator account, but it appears one has to set the application it-self as “run as administrator”

i.e. go to the XWin file, right click, get the properties, go to advanced and check  “Run as administrator”.