HALCON Reference Manual 10.0.2
Table of Contents / Filters / Arithmetic ClassesClassesClasses | | | Operators

add_imageadd_imageadd_imageAddImageAddImage (Operator)

Name

add_imageadd_imageadd_imageAddImageAddImage — Add two images.

Signature

add_image(Image1, Image2 : ImageResult : Mult, Add : )

Herror add_image(const Hobject Image1, const Hobject Image2, Hobject* ImageResult, double Mult, double Add)

Herror T_add_image(const Hobject Image1, const Hobject Image2, Hobject* ImageResult, const Htuple Mult, const Htuple Add)

Herror add_image(Hobject Image1, Hobject Image2, Hobject* ImageResult, const HTuple& Mult, const HTuple& Add)

HImage HImage::AddImage(const HImage& Image2, const HTuple& Mult, const HTuple& Add) const

HImageArray HImageArray::AddImage(const HImageArray& Image2, const HTuple& Mult, const HTuple& Add) const

void HOperatorSetX.AddImage(
[in] IHUntypedObjectX* Image1, [in] IHUntypedObjectX* Image2, [out] IHUntypedObjectX*ImageResult, [in] VARIANT Mult, [in] VARIANT Add)

IHImageX* HImageX.AddImage(
[in] IHImageX* Image2, [in] VARIANT Mult, [in] VARIANT Add)

static void HOperatorSet.AddImage(HObject image1, HObject image2, out HObject imageResult, HTuple mult, HTuple add)

HImage HImage.AddImage(HImage image2, HTuple mult, HTuple add)

HImage HImage.AddImage(HImage image2, double mult, double add)

Description

The operator add_imageadd_imageadd_imageAddImageAddImage adds two images. The gray values (g1,g2) of the input images (Image1Image1Image1Image1image1 and Image2Image2Image2Image2image2) are transformed as follows:

                g' := (g1 + g2) * Mult + Add

If an overflow or an underflow occurs the values are clipped. Note that this is not the case with cyclic images. Furthermore, it is not the case with int2 images if MultMultMultMultmult is equal to 1 and AddAddAddAddadd is equal to 0. To reduce the runtime the underflow and overflow check is skipped. The resulting image is stored in ImageResultImageResultImageResultImageResultimageResult.

It is possible to add byte images with int2, uint2 or int4 images and to add int4 to int2 or uint2 images. In this case the result will be of type int2 or int4 respectively.

Several images can be processed in one call. In this case both input parameters contain the same number of images which are then processed in pairs. An output image is generated for every pair.

Please note that the runtime of the operator varies with different control parameters. For frequently used combinations special optimizations are used. Additionally, for byte, int2, uint2, and int4 images special optimizations are implemented that use SIMD technology. The actual application of these special optimizations is controlled by the system parameter 'mmx_enable'"mmx_enable""mmx_enable""mmx_enable""mmx_enable" (see set_systemset_systemset_systemSetSystemSetSystem). If 'mmx_enable'"mmx_enable""mmx_enable""mmx_enable""mmx_enable" is set to 'true'"true""true""true""true" (and the SIMD instruction set is available), the internal calculations are performed using SIMD technology.

add_imageadd_imageadd_imageAddImageAddImage can be executed on an OpenCL device for byte, int1, int2, uint2, int4, real, direction, cyclic, and complex images. However, since for OpenCL 1.0 only single precision floating point is supported for all devices, and not all rounding modes are supported, the OpenCL implementation can produce slightly different results from the scalar or SIMD implementations.

Attention

Note that the acceleration gained by SIMD technology is highest on large, compact input regions. However, in rare cases, the execution of add_imageadd_imageadd_imageAddImageAddImage might take significantly longer with SIMD technology than without, depending on the input region and the capabilities of the hardware. In these cases, the use of SIMD technology can be avoided by set_system(::'mmx_enable','false':)set_system("mmx_enable","false")set_system("mmx_enable","false")SetSystem("mmx_enable","false")SetSystem("mmx_enable","false").

Parallelization

Parameters

Image1Image1Image1Image1image1 (input_object)  (multichannel-)image(-array) objectHImageHImageHImageXHobject (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*) *allowed for compute devices

Image(s) 1.

Image2Image2Image2Image2image2 (input_object)  (multichannel-)image(-array) objectHImageHImageHImageXHobject (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*) *allowed for compute devices

Image(s) 2.

ImageResultImageResultImageResultImageResultimageResult (output_object)  (multichannel-)image(-array) objectHImageHImageHImageXHobject * (byte / int1 / int2 / uint2 / int4 / int8 / real / direction / cyclic / complex)

Result image(s) by the addition.

MultMultMultMultmult (input_control)  number HTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong)

Factor for gray value adaption.

Default value: 0.5

Suggested values: 0.2, 0.4, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 5.0

Typical range of values: -255.0 ≤ Mult Mult Mult Mult mult ≤ 255.0

Minimum increment: 0.001

Recommended increment: 0.1

AddAddAddAddadd (input_control)  number HTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong)

Value for gray value range adaption.

Default value: 0

Suggested values: 0, 64, 128, 255, 512

Typical range of values: -512.0 ≤ Add Add Add Add add ≤ 512.0

Minimum increment: 0.01

Recommended increment: 1.0

Example (HDevelop)

read_image(Image0,'fabrik')
disp_image(Image0,WindowHandle)
read_image(Image1,'monkey')
disp_image(Image1,WindowHandle)
add_image(Image0,Image1,Result,2.0,10.0)
disp_image(Result,WindowHandle)

Example (C)

read_image(&Image0,"fabrik");
disp_image(Image0,WindowHandle);
read_image(&Image1,"monkey");
disp_image(Image1,WindowHandle);
add_image(Image0,Image1,&Result,2.0,10.0);
disp_image(Result,WindowHandle);

Example (HDevelop)

read_image(Image0,'fabrik')
disp_image(Image0,WindowHandle)
read_image(Image1,'monkey')
disp_image(Image1,WindowHandle)
add_image(Image0,Image1,Result,2.0,10.0)
disp_image(Result,WindowHandle)

Example (HDevelop)

read_image(Image0,'fabrik')
disp_image(Image0,WindowHandle)
read_image(Image1,'monkey')
disp_image(Image1,WindowHandle)
add_image(Image0,Image1,Result,2.0,10.0)
disp_image(Result,WindowHandle)

Example (HDevelop)

read_image(Image0,'fabrik')
disp_image(Image0,WindowHandle)
read_image(Image1,'monkey')
disp_image(Image1,WindowHandle)
add_image(Image0,Image1,Result,2.0,10.0)
disp_image(Result,WindowHandle)

Result

The operator add_imageadd_imageadd_imageAddImageAddImage returns the value 2 (H_MSG_TRUE) if the parameters are correct. The behavior in case of empty input (no input images available) is set via the operator set_system(::'no_object_result',<Result>:)set_system("no_object_result",<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>) If necessary an exception is raised.

Alternatives

sub_imagesub_imagesub_imageSubImageSubImage, mult_imagemult_imagemult_imageMultImageMultImage

See also

sub_imagesub_imagesub_imageSubImageSubImage, mult_imagemult_imagemult_imageMultImageMultImage

Module

Foundation


Table of Contents / Filters / Arithmetic ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH