Skip to content

sub_imageSubImageSubImagesub_imagesub_imagešŸ”—

Short descriptionšŸ”—

sub_imageSubImageSubImagesub_imagesub_image — Subtract two images.

SignaturešŸ”—

sub_image( image ImageMinuend, image ImageSubtrahend, out image ImageSub, number Mult, number Add )void SubImage( const HObject& ImageMinuend, const HObject& ImageSubtrahend, HObject* ImageSub, const HTuple& Mult, const HTuple& Add )static void HOperatorSet.SubImage( HObject imageMinuend, HObject imageSubtrahend, out HObject imageSub, HTuple mult, HTuple add )def sub_image( image_minuend: HObject, image_subtrahend: HObject, mult: Union[int, float], add: Union[int, float] ) -> HObject

Herror sub_image( const Hobject ImageMinuend, const Hobject ImageSubtrahend, Hobject* ImageSub, double Mult, double Add )

Herror T_sub_image( const Hobject ImageMinuend, const Hobject ImageSubtrahend, Hobject* ImageSub, const Htuple Mult, const Htuple Add )

HImage HImage::SubImage( const HImage& ImageSubtrahend, const HTuple& Mult, const HTuple& Add ) const

HImage HImage::SubImage( const HImage& ImageSubtrahend, double Mult, double Add ) const

HImage HImage.SubImage( HImage imageSubtrahend, HTuple mult, HTuple add )

HImage HImage.SubImage( HImage imageSubtrahend, double mult, double add )

DescriptionšŸ”—

The operator sub_imageSubImage subtracts two images. The gray values (g1,g2) of the input images (ImageMinuendimageMinuendimage_minuend and ImageSubtrahendimageSubtrahendimage_subtrahend) 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 and direction images.

* 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, and uint2 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" (see set_systemSetSystem). If 'mmx_enable'"mmx_enable" is set to 'true'"true" (and the SIMD instruction set is available), the internal calculations are performed using SIMD technology.

sub_imageSubImage 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 sub_imageSubImage 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':).

Execution informationšŸ”—

Execution information
  • Supports OpenCL compute devices.

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on domain level.

ParametersšŸ”—

ImageMinuendimageMinuendimage_minuend (input_object) (multichannel-)image(-array) → object (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*)HObject (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*)HImage (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*)HObject (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*)Hobject (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*) *allowed for compute devices

Minuend(s).

ImageSubtrahendimageSubtrahendimage_subtrahend (input_object) (multichannel-)image(-array) → object (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*)HObject (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*)HImage (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*)HObject (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*)Hobject (byte* / int1* / int2* / uint2* / int4* / int8 / real* / direction* / cyclic* / complex*) *allowed for compute devices

Subtrahend(s).

ImageSubimageSubimage_sub (output_object) (multichannel-)image(-array) → object (byte / int1 / int2 / uint2 / int4 / int8 / real / direction / cyclic / complex)HObject (byte / int1 / int2 / uint2 / int4 / int8 / real / direction / cyclic / complex)HImage (byte / int1 / int2 / uint2 / int4 / int8 / real / direction / cyclic / complex)HObject (byte / int1 / int2 / uint2 / int4 / int8 / real / direction / cyclic / complex)Hobject * (byte / int1 / int2 / uint2 / int4 / int8 / real / direction / cyclic / complex)

Result image(s) by the subtraction.

Multmultmult (input_control) number → (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[int, float]Htuple (double / Hlong)

Correction factor.

Default: 1.01.0
Suggested values: 0.0, 1.0, 2.0, 3.0, 4.00.0, 1.0, 2.0, 3.0, 4.0
Value range: -255.0 ≤ Mult ≤ 255.0
Minimum increment: 0.001
Recommended increment: 0.1

Addaddadd (input_control) number → (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[int, float]Htuple (double / Hlong)

Correction value.

Default: 128.0128.0
Suggested values: 0.0, 128.0, 256.00.0, 128.0, 256.0
Value range: -512.0 ≤ Add ≤ 512.0
Minimum increment: 0.01
Recommended increment: 1.0

ExamplešŸ”—

(HDevelop)

read_image(Image1,'fabrik')
dev_display (Image1)
read_image(Image2,'monkey')
dev_display (Image2)
sub_image (Image1, Image2, Result, 1, 100)
dev_display (Result)
(C)
read_image(&Image1,"fabrik")\;
disp_image(Image1,WindowHandle)\;
read_image(&Image2,"monkey")\;
disp_image(Image2,WindowHandle)\;
sub_image(Image1,Image2,&Result,1.0,100.0)\;
disp_image(Result,WindowHandle)\;

ResultšŸ”—

The operator sub_imageSubImage 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>:) If necessary an exception is raised.

Combinations with other operatorsšŸ”—

Combinations

Possible successors

dual_thresholdDualThreshold

Alternatives

mult_imageMultImage, add_imageAddImage

See also

add_imageAddImage, mult_imageMultImage, dyn_thresholdDynThreshold, check_differenceCheckDifference

ModulešŸ”—

Foundation