Fusing several images

In this sample, five images are joined using the F_VN_FuseImagesArray function. This functionality is particularly useful in conjunction with line scan cameras and seamless recording of continuous material flow.

Explanation

The F_VN_FuseImagesArray function accepts an array of (up to ten) images and joins them in a new image. In the following sample program, initially 5 differently colored images with a height of 10px are created. The number can be changed with the variable nImages and the height with nHeight. Be sure to vary this number in the range 1-10 only.

The size of the result image is determined by specifying the image lines with the parameters nFirstLine and nNumLines. This makes it possible to crop the first and last image.

The function F_VN_FuseImages can also be used if only two images are to be joined.

Program

The following variables are declared:

VAR
    hr                  :  HRESULT;
    aImages             :  ARRAY[0..9] OF ITcVnImage;
    ipImageFused        :  ITcVnImage;
    ipImageFusedDisp    :  ITcVnDisplayableImage;
    nImages             :  INT := 5;
    nHeight             :  UDINT := 10;
    aColor              :  ARRAY[0..9] OF TcVnVector4_LREAL := [[255,0,0], [200,50,0], [150,100,0], [100,150,0], [50,200,0], [0,250,0], [0,200,50], [0,150,100], [0,100,150], [0,50,200]];
    i                   :  INT;
VAR

hr

Status variable of the type HRESULT.

aImages

Array with several images that are to be joined together.

ipImageFused

Result image in which several images from aImages are joined together.

ipImageFusedDisp

Displayable result image.

nImages

Number of images to be joined.

aColor

Ten different colors in order to be able to tell the images in aImages apart.

i

Auxiliary variable.

In the program the images in the array aImages are first of all initialized and colored. In order to be able to visually tell the images apart, ten different colors from aColor are used.

FOR i := 0 TO nImages-1 DO
     hr := F_VN_CreateImageAndSetPixels(aImages[i], 100, nHeight, ETcVnElementType.TCVN_ET_USINT, 3, aColor[i], hr);
END_FOR

After that a defined number nImages of images from aImages are joined vertically in the image ipImageFused:

hr := F_VN_FuseImagesArray(aImages, nImages, ipImageFused, 0, nImages * nHeight, hr);

Finally, the image is displayed:

hr := F_VN_TransformIntoDisplayableImage(ipImageFused, ipImageFusedDisp, hr);

Result

nImages = 2:

Fusing several images 1:

nImages = 5:

Fusing several images 2:

nImages = 10:

Fusing several images 3:

Similar samples

Copy image areas