Before

After one click

How to automatically improve picture quality in Delphi.

Pictures downloaded on the net are often of poor quality : bad scans, video captures or too much JPEG compression. Using the mouse and a suitable brush, man can do the work to obtain a better image, but it's boring. The other way is to use a blur function on the whole picture, but this technique erases many details such as eyes or hair.

Optimization

We have to blur large areas, but to save details (edges) of the picture. A simple function exists on all image processing programs : find edges.  A mask is created using this function, and expanded with a blur function to have a larger action.

Image is first seriously blurred (gaussian blur, radius 3), and then the original pixels detected by the edge mask are copied from the original image to the blurred image in order to recover lost details.

Other improvements

Frequently, pictures scanned with an "old" scanner shows saturation in red areas, and darkness or patches of shadow in blue areas. Green areas are generally correct.

The idea is to mix about 12% (or more) of green values into red values and blue values. Result looks better, but of course with less color saturation. The saturation or contrast fonctions can restore color intensity.

The program offers the capability to restore a percentage of original (read) image, function which is very useful to adjust intensity of some actions.

The special Light+ function is better than Correction gamma to obtain bright images such as the background image of this page.

Technical tips

This Delphi 3 demo program (see below) is simple, but fully operational, and can be used as a basis for an image processing program . [efg's note:  change messagebeep(-1) to messagebeep($ffffffff) in later versions of Delphi, like D6 and D7, to eliminate compiler error.]

A zoom show pixels details, save to and undo functions are provided, and a scroll box is used for large pictures. This demo is an extract of a complete image processing program called Estampe.exe. Unfortunately, design and comments are in French. Some original algorithms are used in this program : mix images, very rich text format (see the title above) with extruded letters, progressive shadow and see thru a background in letters), round text (for CD-Roms labels), gradients, select or fill region with tolerance on colors algorithm, etc...

 

j.y.q@wanadoo.fr


Other interesting programs by  Jean-Yves Quéinec:

Jigsaw

Molecules

Sprites Demo (D3-D5)

Gradient Examples

EStampe Labortory

 


since 18 Oct 2002