## Operator ModuloCount

Operator Library: Accumulator

The ModuloCounter counts the number of pixels, lines or frames at the input link. Its count sequence is restricted by the modulo divisor. The number of unique states that a counter may have before the sequence repeats itself is defined by the modulo divisor. The modulo divisor is defined with the Divisor parameter. For example, a modulo divisor of 4 will count "n MOD 4" i.e. 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3 ...

The image dimensions of the output frames are always equal to the image dimensions of the input frames. The pixel data at the output represent the counter result. Note that no pixel values are used. Only the pixel, line or frame index is considered for calculation.

The counter always starts from value zero. The CountEntity parameter can be configured to either count every pixel, line or frame of the input link. For example, if parameter CountEntity is set to PIXEL, the operator will increment its counter with every pixel of the input.

If CountEntity is set to LINE, the counter increments at the beginning of every line and hence, counts the lines of the input link. For example a modulo divisor of four will have the result that all pixels of line zero have value 0. The pixels of line one will have value one, etc. However, the pixels of line 4 will have the pixel values zero again.

If CountEntity is set to FRAME, the counter increments at the beginning of every frame.

In the following examples the operator's usage is illustrated. First example shows two successive frames which have an image width and image height of eight pixels. All pixel values are illustrated as numbers. Frame index 0 represents the initial frame, i.e. the first frame after acquisition start.

• Configuration: Divisor = 6, CountEntity = PIXEL, AutoClear = EoF

As can be seen in this example, the counter is incremented with every pixel when parameter CountEntity is set to PIXEL. The result values are in the range from zero to five, as the Divisor is set to six. In the second frame the operator starts from zero again, as the counter is reset at the end of the frame.

• Configuration: Divisor = 6, CountEntity = LINE, AutoClear = NONE

In this example, the operator counts lines instead of pixels. Thus, every pixel of the image represents the line number. Here, parameter AutoClear is set to NONE. Therefore, the operator continues counting lines in the second frame without a reset at the first image line.

• Configuration: Divisor = 6, CountEntity = FRAME, AutoClear = NONE

The last example shows the counting of frames. Here, the value of every pixel represents the frame number.

If the parameter divisor is changed during acquisition, the new value is applied with the start of the next frame. For 1D input, the new value is applied for the next line. If 0D data is at the input, a new divisor value is applied immediately.

Image Restrictions

• Empty Images

Empty images, i.e., images with no pixels, are not allowed.

### I/O Properties

Property Value
Operator Type O

Bit Width [1, 64] [1, 63]
Arithmetic {unsigned, signed} unsigned
Parallelism any as I
Kernel Columns any as I
Kernel Rows any as I
Img Protocol {VALT_IMAGE2D, VALT_LINE1D, VALT_PIXEL0D} as I
Color Format any VAF_GRAY
Color Flavor any FL_NONE
Max. Img Width any as I
Max. Img Height any as I
 The range of the input bit width is [1, 64]. For signed inputs, the range is [2, 64]. For unsigned color inputs, the range is [3, 63] and for signed color, the range is [6, 63].

### Parameters

Divisor
Type static/dynamic write parameter
Default 1
Range [1..2^OutputBitWidth]

This parameter defines the divisor of the modul operation. The divisor value has to be less equal than 2^OutputBitwidth.

CountEntity
Type static parameter
Default PIXEL
Range {PIXEL, LINE, FRAME}

This parameter defines whether the operator counter is enabled for every pixel, every line or it is enabled once for each frame only.

Option FRAME is only available for image protocol VALT_IMAGE2D. LINE is only available for image protocols VALD_IMAGE2D and VALT_LINE1D. For image protocol VALT_PIXEL0D the parameter will always count pixel.

AutoClear
Type static parameter
Default NONE
Range {EoL, EoF, NONE}

The AutoClear option allows a reset of the counter to zero at either the end of a line, the end of a frame or no clear at all is performed.

If CountEntity is set to PIXEL, all three options of this parameter can be selected. If CountEntity is set to LINE options EoF and NONE are available. For CountEntity FRAME, an auto clear of the operator is not possible.

If the VALT_LINE1D image protocol is used, no clear at the end of a frame is possible. In VALT_PIXEL0D, no auto clear of the operator is available.

### Examples of Use

The use of operator ModuloCount is shown in the following examples: