Periklis Ntanasis:
Master's Touch

fade out

Monimix: A picture is worth a thousand words

The idea!

A couple of months before, I had an enlightenment. I thought that it would be awesome if there were QR (Quick Response) tags that use colors for more information density.

Actually the idea was to combine a set of different QRs and get a colorfull one that could get decombined back to the original set of QRs through the reverse process.

Anyway, a couple of weaks before I have done a short research (by googling it) and have found that this concept already exists in a way and is known by the name High Capacity Color Barcode (HCCB).

HCCB tags are invented by Microsoft and create a 2D barcode using clusters of colored triangles instead of the square pixels traditionally associated with 2D barcodes. You can read more about this in wikipedia.

As you can see this is a different approach of the same idea, put some color in the game. Once again I have thought something that already exists!

However, I really liked this idea so I decided to construct a program that gets N monochrome images and returns a multi-color image that combines all the monochromes.

In it’s simpler form, this is monimix, which is named from monochrome image mix.

Use Cases

Here comes the standar monimix help message that shortly describes it’s functions.

$ java -jar monimix.jar.jar -h
monimix v.0.1 (2012 Nov 07) Copyright (C) 2012  Periklis Ntanasis
<pntanasis@gmail.com>

This program comes with ABSOLUTELY NO WARRANTY; for details visit
http://www.gnu.org/licenses/.
This is free software, and you are welcome to redistribute it
under certain conditions; visit http://www.gnu.org/licenses/ for details.

usage: monimix <command> [arguments] -i [file ...] -o [file ...]

Commands:
-i      Input, white space separated files
-o      Output, in case of demux it's the filename prefix
-b      Makes all the input images black
-c      Changes input image's color to the given color hex value
-t      Turns white background transparent
-w      Turns transparent background white
-f      Force file to be written even if already exists
-d      Debug mode
-h      Prints this help message

Let’s see the main functions in more detail. For starters, let’s say we have 3 images: imageA, imageB and imageC.

Original images

The first main function is the creation of an image that combines our 3 original images. Let’s say that our 3 images have the .png suffix and png format. To do this with monimix we should do java -jar monimix.jar -i imageA.png imageB.png imageC.png -o combo.png.

The 3 images should of course have the same size, i.e. 200x200px.

The result would be the combination image combo.png, which would look like that:

Combination image 1

The second main function is the reverse process that would give us the 3 original images. To do that with monimix we should do java -jar monimix.jar -i combo.png -o image. This would produce 3 images of size same as the one of combo.png and with names image0.png, image1.png and image2.png. All the outcome images will have white colored background and black colored monochrome pictures.

Special Cases

There are some special cases that monimix is designed to overcome.

Original Images with Transparent Background

If an image, i.e. imageA.png would have transparent background, then when decombining the combo.png would produce an image with white background.

To get the image to it’s original form, one with knowledge of the original image could use monimix like that: java -jar monimix.jar -t -f -i imageA.png -o imageA.png.

I used the -t switch to set the white background to transparent and the -f switch to overwrite the imageA.png file silently. Otherwise, monimix would asked me if I wanted it to be overwritten or not.

Original Images that aren’t Black colored

Just like before, the decombining process would produce black images. A monochrome image however could be any color.

One with knowledge of the original image could use monimix to change the color of the produced image like that: java -jar monimix.jar -c #FF0000 -f -i imageA.png -o imageA.png.

Original Images that aren’t monochrome

This is handled automatically by monimix during the combination but however getting the original image back is out of the question.

Let’s see an illustrated example of all the above things.

monimix steps

Let’s see every step in detail:

  1. ImageB.png and ImageC.png have transparent background.

  2. java -jar monimix.jar -i image*.png -o combo.png and we get combo.png

  3. java -jar monimix.jar -i combo.png -o image and we get image[1-4].png (it’s actually 0-3 :P). As you can see imageD.png isn’t fully restored.

  4. java -jar monimix.jar -t -f -i image2.png -o image2.png and java -jar monimix.jar -t -f -i image3.png -o image3.png to set the backgrounds to transparent

  5. java -jar monimix.jar -c ff0000 -f -i image2.png -o image2.png to change the image’s color from black to red.

Image Combination

Let’s see how the image combination is done in more detail. This was the most challenging part of monimx.

First of all we need to determine how many different colors we are going to need. If we want to combine 2 images we need 3 different colors, to combine 3 we need 7 and so on. The generic formula for the number of colors when combining N images is this:

number of colors formula

Then, we combine 2 images at a time. At first we combine the first 2 images and after that we combine the combined one with the next image. The trick is that when the combined image isn’t colliding with the next it keeps its previous colors.

Something else worth mentioning is that the colors are placed depending the previous color that was visible. This means that i.e. color B will always be on top of color A.

Image Decombination

While decombining the images we need to reverse the combination process.

The only tricky part worth mentioning is that first of all we need to find the number of images that were used to produced the combined one. To do this we have to find the number of the maximum possible colors of the combined image. Just counting the colors that are present isn’t enough because this number could be smaller than what we want.

To get this more clear think of combining 3 images that aren’t colliding anywhere. The combination would contain only 3 different colors. If we count the colors in order to find how many images were combined then we mistakenly would think that there were 2 original images instead of 3.

So we find the number of combined images by the max RGB value of all the visible colors. If we get this number everything else is trivial.

The Ultimate Goal

The original idea was to use all these stuff for something like that:

monimix and QRs

In this colored QR we have 3 times more info in the same space than a black one.

Things to think

A version that would receive images from a webcam or smart-phone cam would need some modifications.

To be more precise, we should use only highly distinct colors, something that would limit the number of images that could be combined. Also, we should remove the noise from the camera by finding the distance from the set of colors that we used and replace every pixel’s color with the one closer to the ones of the set.

Conclusion

I strongly believe that this concept could be used with smart-phones etc. However, I am not sure if it’s the best way to succeed the greatest information density. I am not motivated enough at this time to test this concept myself but if one tries this out, he’s more than welcome to leave a comment below.

Comments

fade out