Sharp picture

Image assembler software


Fast real-time image processing handler for robotic defects recognition systems. This software implements a focus stacking algorithm made on C++ language. Focus stacking is useful when your depth of field is shallower than all the objects you wish to capture. In macro photography, this is very common. Instead, you take a series of pictures where you focus progressively throughout the range of images, so that you have a series of images that, in aggregate, have everything in focus. Focus stacking, then, merges these images by taking the best focused region from all of them to build up the final composite image. There is a sample program in folder 'software'. It assumes that there is a subdirectory called "input" which contains the source images. It generates an output called "result.bmp" Max input image size 5000px width for 25Mp High resolution camera. I have also included some sample images in the input directory to allow you to experiment with the code without having to shoot your own set of images.

Software usage

This program search for all files with predetermined name and types: *.bmp *.jpg, *.jpeg, *.png in a subdirectory "samles", and then merges them together. Algorithm aligns and scales image array to exemplary master-frame, then select, copy and merge only well focused area from different layers. The final image is put in to the file result.bmp If you use any options with images show windows, for close it and continuation press any keybord key. Image processing result can be downloaded here: Image assembly example

Below you can see, from 6 photos with shallow depth of field the final sharp picture is assembled.

Stacking Result:



If you run the program without parameters, it print a list of all possible options.
It is convenient to use batch files for different configurations.
The program folder contains the following examples of *.bat files:

• img-color.bat (slow)
image processing with color

• img-gray.bat (fast)
image processing without color

• img-resized.bat (very fast)
reduce image size before processing

• imgstack.cfg
use this file if call the application without argument string

Argument list

-i string
Load image array from: ../path/folder/filename*.* Here first star sign (*) must be image number. Input file format is .* - bmp, png, jpg, gif. Number 0 use for based master frame definiton.

Case 1: Img0.bmp - img frame with number 0. Exaple: -i step0.jpg -n 4 Here loading img array: step0.jpg... step3.jpg, 4 frames

Case 2: Img2[3].bmp - frame number 3 used like begin master-frame for array Img2. Example: -i Camera2[3].bmp -n 6 Here loading img array: Camera2[3]... Camera2[8].bmp, 6 frames

-r value
Reduce incoming image array size by width & heigth, in persents.

-n value
Image`s count number for loading.

Show output image on display.

-w string
Write output image: ../path/folder/filename.* - bmp, png, jpg, gif.

Do image output chromaticity, with color enabled.

-p value
If used this options, put here pointer to mem array. And image`s will be fast downloaded from shared memory.

-f value
Frame align filter threshold forced value.

Show command argument`s list

Show image processing time, ms

Show aligned images

-l string
Write aligned images to: path/folder

Show Laplasian vector`s field

Show programm usage help