BlurJoin

Program status

Program created 2004
Program last touched 2006
Status Finished

Originally a school project for the x86 assembler class. This program takes a series of images and composes an image from the sharpest parts of each image using a technique that is known as semi-wavelet focusing.

Abstract

Images produced by microscopes suffer from small depth of focus. In the past, this problem was reduced by microscoping only samples that were thin enough to fit into this depth. However, this was unsatisfactory, and thus techniques were sought that would allow us to overcome this limitation. When microscoping an object larger than the depth of focus, an image sequence can be produced, each focused at different depth. An example is shown below:


Images from EPFL website.

Theory - Using wavelets

The goal is to produce a sharp image. As a measure of sharpness, the magnitude of the gradient can be used. Therefore we can re-formulate the goal as to obtain an image with high gradient magnitudes and (to maintain resemblance with the original images) with low frequencies similar to the original series, both gradient and low frequencies measured locally.

Wavelet decomposition seems as the perfect tool: it splits the image into gradient and low frequencies in a local sense. If we wavelet-transform each image, then merge the gradients using their maximum and keep the low frequency of one of the source images, we could obtain the desired image. Also, we will not only get a sharp image, but a depth-map as well, simply by remembering in which source image the maximum was.

Surprisingly, this simple approach works, however, it can be improved. Due to the fact that the maximum gradient magnitude may not be the "sharpest" one, we can improve the visual appearance of the image by either post-processing the depth map (blurring) or manipulating the build process, for example by choosing a maximum in 3x3 neighborhood instead of the point maximum.

The following images were created from the series above (with triple accuracy steps) using simple maximum criterion and 3x3 averaging postprocessing:

In this particular example, the averaging process seems worse than the simple approach; however, this is not the usual case. Such an anomaly is caused by the sparseness of the data. For the averaging to work, we would need a more dense sequence.

Quick documentation

BlurJoin is a program designed to perform the above-mentioned method of sharpening an image sequence. Haar wavelet is used for the transformation.

When run, the main window is shown. You can load in an image sequence using the "Add..." button, and further manipulate the sequence using "Remove", "Clear" , "^" (up) and "v" (down) buttons.

The "Haar WT..." button takes the current image and runs the wavelet transformation on currently selected image. All three modes, PAS (meaning Object Pascal implementation), PASM (inline OP Assembler) and ASM (external Assembler) are executed, and compared. This is for ASM validity checking purposes only. The resulting images can be saved to disk using a right-click menu.

If the "Save HWT" checkbox is checked, the results of the wavelet transform are saved to disk in a raw format. It can be used later to run an inverse transform or to examine the results. A name for the file is automatically generated by changing the extension to ".[method].hwt". Method will be one of the following: PAS, PASM, ASM, (BJ); BJ standing for BlurJoin results.

"Haar IWT..." button will perform the inverse wavelet transform. It will ask for a ".hwt" file which will then be transformed and shown as an image. It can be used to verify wavelet transform algorithm validity and reversability.

"BlurJoin" button performs the whole sharpening described above. It will also postprocess the depthmap if a postprocessing method is selected. The "WT Depth" determines how far into the wavelet decomposition will the maximum criterion be used (essentially meaning the maximum size of edge detected). Results of this process are the sharp image, depthmap, and (if appropriate) the postprocessed depth map. If the "Save DEP" checkbox is checked, a depthmap will be saved in a raw format to a ".dep" file.

Example Images

Fly, simple maximum Fly, 3x3 avg, wt depth 4 Fly, 3x3 avg, wt depth 6 Fly, simple maximum depthmap
Source images from CMP website.

Clearly, averaging has improved the visual appearance of the result in this case.


Technical method details: Each image is wavelet-processed using Haar base into a left Mallat tree. Then in each level of the tree the sequence of images is scanned for the largest values (high value = sharp edge). Using these high values, the final image is reconstructed via inverse process. Although not perfect, this method is usually sufficient for illustrative purposes.

Technical program details: The application is written mostly in Delphi. Only the wavelet processing parts are hand-optimized using x86 + x87 assembly. The program therefore shows also the means of linking Delphi code with assembler code. For comparison, the transform functions are also implemented in Pascal, though not used.

The samples in the download section were downloaded from cmp felk site, their copyright is unknown

Downloads

BlurJoin compiled application (EXE) 238 KiB
BlurJoin sources (PAS + ASM) 28 KiB
Example images 1 (ZIPped BMPs) 26.9 MiB
Example images 2 (ZIPped BMPs) 29.9 MiB


Generated: 9.8.2011 15:05:01 by WebComposerWebComposer.