Mœud deux

August 7, 2018

Pairing functions are fun. Last week, we had a look at the Cantor/Hopcroft and Ullman function, and this week, we’ll have a look at the Rosenberg-Strong function—and we’ll modify it a bit.

Read the rest of this entry »


Mœud

July 31, 2018

Pairing functions are used to reversibly map a pair of number onto a single number—think of a number-theoretical version of std::pair. Cantor was the first (or so I think) to propose one such function. His goal wasn’t data compression but to show that there are as many rationals as natural numbers.

Cantor’s function associates pairs (i,j) with a single number:

…but that’s not the only way of doing this. A much more fun—and spatially coherent—is the boustrophedonic pairing function.

Read the rest of this entry »


The Well-Tempered Palette (Part 3)

July 24, 2018

This week, we’ll discuss a cool, but failed, experiment.

In the last few weeks (of posts, because in real time, I worked on that problem over a week-end) we’ve looked at how to generate well distributed, maximally different colors. The methods were to use well-distributed sequences or lattices to ensure that the colors are equidistant. What if we used physical analogies to push the colors around so that they are maximally apart?

Read the rest of this entry »


The Well-Tempered Palette (Part 2)

July 17, 2018

Last week, we’ve had a look at how to distribute maximally different colors on the RGB cube. But I also remarked that we could use some other color space, say HSV. How do we distribute colors uniformly in HSV space?

Read the rest of this entry »


The Well-Tempered Palette

July 10, 2018

When we use false color to encode useful information in an image, it helps greatly if the colors are meaningful in themselves (like a rainbow to encode heat) or maximally different when the image is segmented (like a map showing geologic provinces). But how do we chose those maximally different colors?

Somehow, we need a maximally distributed set of points in RGB space (but not necessarily RGB). We might have just what we need for this! We’ve discussed Halton sequences before. They’re a simple way of progressively and uniformly distribute points over an interval. The sequence starts by the ends of the interval then progressively fills the gaps. It generates the sequence 0, 1, 0.5, 0.25, 0.75, 0.125, 0.625, 0.375, 0.875, …

Read the rest of this entry »


HSV and HSL (colorpsaces XI)

July 3, 2018

HSV (hue, saturation, value) and HSL (hue, saturation, lightness) are two intuitive, but computationally cumbersome, colorspaces.

The basic idea behind these colorspaces is the good ol’ color wheel, where primary colors are placed on a triangle and secondary colors between; complementary colors are to be found opposite on the circle. That’s intuitive enough, but we still have to make it into a workable colorspace.

Read the rest of this entry »


Linear Feedback Shift Registers (Generating Random Sequences XII)

June 26, 2018

While working on a project with a student, I had a look at linear feedback shift registers as a mean of generating (pseudo)random values. The principle isn’t very complicated: you select a number of bits in the register and use them to compute one bit value, you shift the register by one position and insert the new bit in the vacant spot.

Typically, the function is merely a series of exclusive ors, which basically computes the parity of the selected bits. This will help us create an efficient implementation—maybe using the compiler intrinsics.

Read the rest of this entry »