Shortest Paths with Curvature and Torsion

December 21, 2013

Johannes Ulén, Fredrik Kahl and I have recently been to the International Conference on Computer Vision to present our paper Shortest Paths with Curvature and Torsion, in which we explore applications of higher-order regularization for shortest paths.

See the paper here.

The code is available here.


August 5, 2013

Consider the following code:

void f(const int &) { cout << 1; }
void f(int&&) { cout << 2; }

template<typename T>
void g(const T&) { cout << 1; }
template<typename T>
void g(T&&) { cout << 2; }

int main()

  int i;

What will the code print? The answer is “2212,” which can be quite surprising.

Read the rest of this entry »

Rounding of strings

April 23, 2013

Consider the following program:

int main()
auto f = 1.0f;
printf(“%f\n”, f / 0);
printf(“%.1f\n”, f / 0);
printf(“%.2f\n”, f / 0);
printf(“%.3f\n”, f / 0);

f = 0.0f;
printf(“%f\n”, f / 0);
printf(“%.1f\n”, f / 0);
printf(“%.2f\n”, f / 0);
printf(“%.3f\n”, f / 0);

With Visual Studio 2012, it outputs the following:



The strings are also rounded! That is, ‘#’ + 1 == ‘$’. This can be a bit surprising.


Graph cuts in nVidia’s NPP toolbox (imageSegmentationNPP)

February 18, 2013

Note: This post has been updated after I received some help from nVidia’s Timo Stich. It turned out that some weights have to be set to zero; otherwise, CUDA gives an incorrect answer.

Today, I downloaded the latest version of nVidia’s CUDA to try out the graph cut segmentation present in NPP.

There is an example called “imageSegmentationNPP” which solves a two-dimensional (4-connected) problem. These are the results I got:

GPU: 84 ms.
CPU (GridCut): 24 ms.
Read the rest of this entry »


June 15, 2012

I have briefly tried the GridCut code ( and performed the same experiments as in the previous post. Below are the updated graphs.

The GridCut code performs very well for graphs with a reasonable amount of regularization, but becomes very slow for a high amount of regularization, just as BK.

Cell Classification

May 10, 2012

Johannes Ulén, Fredrik Kahl and I recently worked on a data set from the ICPR Contest on HEp-2 Cells Classification. The task is to classify images of cells as one of six possible categories. The image below show examples from the data set:

Each row shows images from one class.

Each row shows randomly selected images from one class. Click to enlarge.

Read the rest of this entry »

Maximum flow for vision

January 30, 2012

Last week, I decided to try out the IBFS maximum flow algorithm for vision applications for the first time. The algorithm is due to A.V. Goldberg, S.Hed, H. Kaplan, R.E. Tarjan, and R.F. Werneck, who have released an implementation which uses the same interface as the commonly used algorithm by Boykov and Kolmogorov.

My test was very simple, I generated a 128×128 8-connected grid graph, with source and sink arcs computed from the ‘cameraman’ image. I then let the weights of the arcs between the nodes vary several orders of magnitude. The result is quite telling:

The BK algorithm takes over 100 seconds to compute the maximum flow when the regularization is high. By contrast, the IBFS algorithm always uses less than 1 second. Here is the logarithmic plot: