Archive for the ‘Coding’ Category.

Hex/Bin/Dec Converter And Calculator

When working with micro-controller projects, it is often necessary to perform calculations in binary and hexadecimal forms. While almost all calculator tools (such as calc under Windows and gcalctool in Linux) can handle such tasks, they are designed for general purpose calculations and not geared specifically towards working with digital circuits. Continue reading ‘Hex/Bin/Dec Converter And Calculator’ »

POV And POV Image Encoder

One of my recent projects was to build a POV display device. There are already many microcontroller based POV devices out there, but most of those I have seen use around eight LEDs and have fixed font types. So I thought of developing something that is larger (e.g. using more LEDs) and more flexible (e.g. can display both text and images). Continue reading ‘POV And POV Image Encoder’ »

4 Digit 7 Segment Display Using Arduino

I was inspired by Paul’s 7 segment display and decided to build one myself. He used 4 common cathode 7 segment displays. In his original schematics, all the segments within a display shared one current limiting resistor which unfortunately affect the display brightness when different numbers of segments are lit. I happened to have two common anode dual 7 segment displays (QDSP-G545) so I decided to use them and four 74HC595 shift registers to build a four 7-seg display. Realizing that other people might be using either common anode or common cathode displays, I also built a library that can be used for either case. Continue reading ‘4 Digit 7 Segment Display Using Arduino’ »

A Simple Thread Barrier Implementation

Sometimes a group of concurrently running threads may need to rendezvous at a certain point in time before they can further proceed. This situation commonly arises in areas like event simulation, where the events are synchronized via a clock event (see illustration below): Continue reading ‘A Simple Thread Barrier Implementation’ »

A Simple Program for Finding Palindromic Prime Numbers

A palindromic prime (palprime) is a prime number that is also palindromic. So out of curiosity I wrote a simple program a few days ago that can find the palindromic numbers within a given range. Here is the code in C++: Continue reading ‘A Simple Program for Finding Palindromic Prime Numbers’ »

Poor Man’s Parallel Task Dispatcher

Even though multi-core processors are almost ubiquitous nowadays, applications are slow to catch up. Of course, one could always re-write the applications in order to take the full advantages in a multi-core environment. But it is not an easy undertaking. Continue reading ‘Poor Man’s Parallel Task Dispatcher’ »

C++ Recursive Directory Search Under Linux

I was trying to search for some code examples on how to do a recursive directory search under Linux using C++ the other day. But to my surprise, I could not find any place that offers a complete example. So I decided to post my code here after I created my own and hopefully you will find it helpful. Continue reading ‘C++ Recursive Directory Search Under Linux’ »

Magick++ Missing Delegate Error

As I wrote last time, I did a clean Ubuntu 9.04 install on my main PC. Continue reading ‘Magick++ Missing Delegate Error’ »

Canny Edge Detection Auto Thresholding

In the example I gave in “Interfacing IPP with Magick++“, I illustrated how to use Intel’s Integrated Performance Primitives (IPP) to perform edge detection. One issue with Canny edge detection algorithm is that we need to specify a high threshold and a low threshold. How to select those threshold values affect the quality of the detected edge greatly. And in my previous example, the threshold values were chosen manually. In this blog post, I will examine a couple of simple methods that can be used to automatically determine the threshold values. Continue reading ‘Canny Edge Detection Auto Thresholding’ »

C++ IDEs Under Linux

So far I have been mainly using KDevelop and Code::Blocks as my C++ development IDEs. Recently, I started using NetBeans IDE for C++ and I started to like it quite a bit. Continue reading ‘C++ IDEs Under Linux’ »

An Image Class Based On IPP

A couple of weeks ago, I wrote about how to interface Integrated Performance Primitives (IPP) with Magick++. While IPP offers excellent performance advantages, it does not come with the easiest programming model. Fortunately, it is easy enough to create a C++ wrapper on top of IPP and provide an easier to use programming interface. Continue reading ‘An Image Class Based On IPP’ »

Interfacing IPP with Magick++

Intel’s Integrated Performance Primitives (IPP) is a low level C++ library. It provides routines that are highly optimized on Intel processors. I recently started using it because its vast speed advantage in signal and image processing applications. Continue reading ‘Interfacing IPP with Magick++’ »

Matrix Multiplication Performance in C++

A few days ago, I ran across this article by Dmitri Nesteruk. In his article, he compared the performance between C# and C++ in matrix multiplication. From the data he provided, matrix multiplication using C# is two to three times slower than using C++ in comparable situations. Continue reading ‘Matrix Multiplication Performance in C++’ »

Two Level Tree and Its Applications — II

In my previous post, I discussed how to merge and split a two level tree. Before moving on to discuss its applications, let us take a look at the output of the sample program I gave before.  Continue reading ‘Two Level Tree and Its Applications — II’ »

Two Level Tree and Its Applications — I

A two level tree is a simple tree data structure. Unlike in a typical tree where the tree depths could be arbitrary, a two level tree has only two levels as its name suggests. Two level tree is also equivalent to a star. Continue reading ‘Two Level Tree and Its Applications — I’ »