Thursday, July 25, 2013

install_name_tool on OSX

Usually I do not have to cope with OSX. But today I had to and Apple's dylib policy drove me crazy (especially when there are many dylibs with absolute paths to their dependencies). The blogpost that saved the day for me introduced the handy tool install_name_tool. Calling with the -id switch, you can change the install name of the target. When used with the -change switch, install_name_tool will change the path to the dependency according to your settings (paths preferably relative!).
I wrote this post in case I ever have to deal with OSX again. Knowing that makes life a lot easier.

Saturday, July 20, 2013

blog recommendation

Whoever is interested in C++ should have a look at http://herbsutter.com/. Amongst other occupations Herb Sutter used to be a chair of the ISO C++ standards comittee. That qualifies him to produce interesting and informative posts on C++, especially with regard to standard C++.

For me the section Guru of the Week is  particularly useful. Every week there's a C++ problem (not a specific implementation task, but general questions regarding standard C++) that you can try to solve yourself. If you need a hint or are just interested in the solution, there is always an exhaustive answer. The problems are being updated to match C++14, therefore many problems are currently offline for revision. However, until they are back again, I recommend having a peek at the remaining ones.

Thursday, July 11, 2013

Disable CPU throttling in Debian (aptosid)

When building ATLAS you cannot have CPU throttling enabled:
"CPU Throttling apparently enabled! It appears you have cpu throttling enabled, which makes timings unreliable and an ATLAS install nonsensical. Aborting. "

Disabling throttling is just a single command (for each cpu):
cpufreq-set -g performance -c  <CPU>

Where CPU denotes the cpu index (0 through 7 in my case). If you do not have cpufreq-set, you can get it from the package cpufrequtils.

Wednesday, July 3, 2013

online UML diagrams

yuml is a website that allows you to draw UML diagrams online. You can export your diagrams to various formats, such as svg, png, json.


sample diagram generated using yuml

Sunday, June 30, 2013

Elisp Function to Add License File at Beginning of Buffer

I wrote a small function that allows for reading a file and adding it at the beginning of the buffer. This comes in handy when you need to add license terms to all your source files.
The function can be found in my .emacs on github. There is also a fake license containing just one line for trying that function.

The call syntax is
(add-license-handling license_dir license_type)

license_dir is the directory containing the license file (defaulting to ~/.emacs.d/license) and license_type is the license that you want to use stored in the file <license_dir>/<license_type>. You will also need the functions get_default_license_dir and get_default_license_type from my .emacs file to get this to work.
If you want to set different default values, add this to your .emacs:

(setq default_license_dir "~")
(setq default_license_type "FAKE")

Monday, June 10, 2013

Polymorphic Allocators and Concepts in C++14

With the release of the first feature complete C++11 compiler gcc 4.8.1, you might consider taking a peak at the upcoming standard C++14.
Two - in my opionion - very interesting aspects are:

  1. Polymorphic Allocators - The object type should be independent of the container. This is especially important when you consider two containers whose data have been allocated with different allocators. In previous standards they are incompatible, but with C++14 they will not depend on the allocator anymore.
  2. Concepts are finally introduced in C++. Concepts are very helpful for template programming and restricting the type of the template parameters. This will make interfaces much clearer and also reduce cryptic template error messages, very helpful both for developers and users. Examples for concepts are Iterators, Containers, Numerical, etc.
Those are only two features of many to come in C++14. If you want to check out more propositions and ideas, there is a blog that dedicated four rather long posts on papers regarding C++14:
1 2 3 4

Sunday, June 9, 2013

Improving an Object Detector and Extracting Regions using Superpixels (CVPR 2013)

As usual there will be shortpapers in our journal club on Thursday. The one I picked titled "Improving an Object Detector and Extracting Regions using Superpixels" is from the upcoming CVPR and the authors are Guang Shu, Afshin Dehghan, Mubarak Shah from the Computer Vision Lab at the University of Central Florida. A pdf can be obtained here.
Their goal is to improve offline-trained object detectors such as Deformable Parts Model (DPM), that are trained generally on training data that do not neccessarily represent future test data. Variant illuminations, background and camera viewpoints will degrade detector performance. The authors' approach can be subsumed in four steps:

Initial Detection

Using a DPM detector with a low threshold \(t_d\) (design parameter) they obtain a large number of true detections and also many false alarms. Given the detector's confidence scores they classify each target positive or hard. Negative examples are obtained from background (without overlap).

Superpixels and Appearance Method

Using SLIC Superpixels each target is segmented into a given number of superpixels \(N_{sp}\)(design parameter, chosen such that each superpixel is roughly uniform in color and preserves object boundaries). Each superpixel is described by a five-dimensional feature vector containg the average CIELAB colorspace value and the average location of all contained pixels.
Using K-Means an \(M\)-word (design parameter) vocabulary is created and superpixels are aggregated into an \(M\)-bin L2-normalized histogram for each target (representation in a Bag-of-Word (BoW)-fashion).

Classification

A support vector machine (SVM) is trained for classification of hard examples, based on positive and negative examples. Hard examples with high scores will get the label positive, low scores will be negative. The SVM is retrained until all example labels stay unchanged.

Region Extraction

To get en estimate of the actual shape of the target rather than a bounding box a confidence map for each superpixel belonging to the target is calculated. First all superpixels of the negative samples are clustered into \(M_n\) (design parameter) clusters using CIELAB color features. For every superpixel of a positive example the similarity to each of the negative cluster centers is measured by
\[ W_{i,j} = exp(||Sp(i) - clst(j)||\times prior(j))\]
where \(W_{i,j}\) is the respective entry in the similarity matrix, \(Sp(i)\) is the i-th superpixel of a positive example, \(clst(j)\) is the j-th negative cluster center, \(prior(j)\) is the prior probability that a cluster belongs to the background, defined by the number of superpixels in that cluster.
The similarity matrix can be used to calculated the confidence \(Q_i\) of superpixel i belonging to the target
\[Q(i) = 1 - max_jW_{i,j}\]
Using this confidence map to form unary potentials \(\Psi(c_i|s_i)\) and pairwise edge potentials (to account for smoothness) \(\Phi(c_i,c_j|s_i,s_j)\), the energy in the sense of a Conditional Random Field (CRF) needs to be minimized, to achieve the most probable solution.
\[E=\sum_{s_i\in Sp}\Psi(c_i|s_i)+\omega\sum_{s_i,s_j\in Edge}\Phi(c_i, c_j|s_i, s_j)\]
\(\Phi\) is specified in the paper. \(c_i\) is the label for each superpixel \(s_i\). The weight between unary and 
binary terms \(\omega\) is another design parameter.

Experiments

The proposed method is compared to the original DPM approach and outperforms it on all datasets. The used values of the design parameters are specified (except for \(\omega\), but the authors do not state how they obtained them.
\[t_d = -2, N_{sp} = 100, M = 400, M_n = 200, \omega=?\]
It would be very interesting to know how problem specific or general those parameters are.

Conclusion

The paper is quite straight forward, well written and easy to understand. Few typos and misaligned images indicate that the paper's been finished just before the deadline.
When I first read the title and abstract, I was hoping for a method that did not need segmentation candidates and would not introduce many design parameters. Both assumptions were wrong (first segmentation using DPM, five design parameters), but the approach might still be interesting to the cell tracking project I am working on.