Image halving and Doubling

With Anti-aliasing

By Charles Douglas Wehner

Halve and Double

HALVE.COM and DOUBLE.COM are DOS programs of precisely defined behaviour.

HALVE takes pixels from an image in pairs, and from the row below in pairs, and averages them. Thus four pixels are reduced to one of average colour. The width and height of the image are halved. This has applications in image storage and in anti-aliasing.

DOUBLE takes an image and makes four identical copies of each pixel - two pairs of columns in two rows. This doubles the linear dimensions of the image without interpolation, ready for manipulation. An image enlarged by DOUBLE will be restored to exactly what it was before, when HALVE is used, unless, of course, the image has been otherwise manipulated.

Be warned, though, that an image that is first HALVEd and then DOUBLEd will NOT be restored to its original state.

Photographs

Most cameras in the early 2000s have Bayer-pattern sensors:

The full set of red, green and blue primary colours are not measured at any point. That is currently only possible with the Foveon sensor. However, near every red measurement point are four greens that can be averaged, and four blues.

Near every green measurement point are two reds to average, and two blues. Near every blue, the pattern is as for red, except that red and blue are swapped. This is not shown.

This process is a form of interpolation:

The "Ten megapixel" sensors we are sold have, in fact, only ten million measurement points. If we consider a true pixel to be an RGGB cluster of four measurement points, it is in fact only a two-and-a-half megapixel sensor.

Added to that is the fact that the measurement points are usually at 314 to the millimetre, whilst few lenses can achieve a "minimum circle of least confusion" below a hundredth of a millimetre:

This is done deliberately, to avoid coloured Moiré effects when areas of fine black-and-white detail interact with the Bayer pattern.

From what has been said, one can see that one can safely halve the dimensions of a camera original without losing any detail. The only difference is that enlargements of a small area may show the pixels (be "pixelated") on the halved image, but not on the original.

The author accepts no responsibility. The tool is free. That is service enough. Some people imagine that definition is lost. If you use the tool, you do it on your own responsibility. Bear in mind that at the second and subsequent halvings definition is indeed lost.

How to Use

You put your photograph, as a 16 megacolour bitmap, in a directory together with HALVE.COM. Then you go to the DOS prompt and type "HALVE MYPIC", where "MYPIC.jpg" is the name of your picture. A file called "HALVE.jpg" is made. It has half the dimensions.

If you want to halve the HALVE.jpg image again, you have to change the name.

DOUBLE.COM is used in much the same way.

Anti-aliasing

The author's godfather was Dr. Rudolf Conrad, the world authority on colour photogravure. He had discovered that an image could be sharper than the "scratches" used to make it - and this before the Second World War.

Computer graphics are taking over from photogravure, and yet the principle still applies. The image can be sharper than a pixel. How does that work? Well, it is visual psychology.

There is no denying that the arrow on the right is sharper than that on the left. Something is leading the eye to perceive such sharpness.

The sharper image was actually made at four times the definition required. That is to say, four times in each dimension. When shrunk down by the use of "HALVE" twice, it become the anti-aliased image. And enlarged again by the use of "DOUBLE" twice, the image looks like that in the second image above. The changes can be seen.

Information has been shifted out of the "spacial domain" into the "brightness domain". That is to say, as a line gets thinner and thinner until it is smaller than a pixel, it then becomes feinter and feinter. One can even see a trace of brightness beyond the tip of the arrow.

The non-anti-aliased image has no such half tones (third image above). Therefore it cannot lead the eye into perceiving any sharpness beyond the size of a pixel.

Experience has shown that doubling the image prior to working upon it, and halving at the end, delivering a 2x2 anti-alias, creates a vast improvement over no anti-aliasing at all. Making the graphic four times bigger, and halving twice makes 4X4. This is perceivably better than 2X2. 8X8, however, delivers litte improvement over 4X4 and 16X16 shows no improvement over 8X8.

A 32X32 anti-alias would be pointless. What happens is that the pixel is evaluated to a precision of one part in 1024 (to TEN-BIT precision). However, when packing the pixel into bytes one throws away the two extra bits of precision.

Here we see the effect of anti-aliasing when an ellipse is being drawn:

The entry of text into an image uses similar principles:

If one is using 4X4 anti-aliasing, the text has to be four times larger. That means one needs to use 72 point text to achieve the 18 point result shown. If such large typeface is not available, one may be restricted to 2X2 anti-aliasing, but even a little is better than none.

Here is another example:

An attempt was made to multiply up the size of the image using commercial software prior to the entry of text. The result was that after the first halving all seemed well, but after the second, the image was blurred:

This leads to two concepts.

Firstly, some commercial software, when doubling the dimensions of the image, will interpolate. It will deliver pixel 1, then an average of 1 and 2, and then 2, an average of 2 and 3 and so on. Interpolation of this form is a good idea if the doubled size is to be the final image. It hides the pixelation somewhat. If it is not the final size, it degrades the image. Upon halving, one finds that one ends up with a mixture of pixels 1 and 2 as the first pixel, instead of just pixel 1. This was the point where it was decided to write "DOUBLE.COM" in such a way that each pixel would simply be doubled in the rows and columns, and upon the use of "HALVE.COM" would return exactly to its former status.

The second idea is that it is sometimes good to blur an image slightly before the words are put in. This shows the sharpness of the anti-aliased text to its best advantage.

WINZIP ZIPPED FILE
http://wehner.org/tools/halve.zip

Home

(C) 2010 Charles Douglas Wehner.
Use freely but do not plagiarise.