Posts in the «Algorithms» Category

Quick line segmentation

From the Equation OCR front line…


Splitting up handwritten calculations into single lines.

Algorithm description:

First map all the strokes on the y-axis. Then travel along the axis and record the the ink density (number of strokes underneath). Remember local maximums. If the density falls below a certain percentage (tolerance) of a last local maximum – insert a break line.

C# code:

…

Tags: ,

C# benchmark of 2^x optimizations

As promised last week I’m going to compare three methods of optimizing 2 ^ x calculation:

…

Tags: ,

2^x optimization for double type

Signal processing often requires moving between logarithmic & linear domains. In audio area we can talk about Octaves (logarithmic representation) and Frequencies (linear representation). Octave -> Frequency conversion corresponds to transformation x = 2 ^ x.

Most programming languages provide support for such calculation, for example Pow(a, b) in C#.
Those functions however tend to be time consuming. We can take advantage of the fact that in our case a = const = 2 and optimize the calculation.
Let’s start with equation:

a ^ ( b + c ) = a ^ b * a ^ c

…

Tags: ,