AFBR-S50 API Reference Manual v1.5.6
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
Loading...
Searching...
No Matches
Pixel Channel Mapping

Pixel Channel Mapping. More...

Collaboration diagram for Pixel Channel Mapping:

Macros

#define ARGUS_PIXELS_X   8
 The device pixel field size in x direction (long edge).
 
#define ARGUS_PIXELS_Y   4
 The device pixel field size in y direction (short edge).
 
#define ARGUS_PIXELS   ((ARGUS_PIXELS_X)*(ARGUS_PIXELS_Y))
 The total device pixel count.
 
#define PIXEL_XY2CH(x, y)   ((((y) << 3U) & 0x10U) | (((x) ^ 0x07U) << 1U) | ((y) & 0x01U))
 Macro to determine the pixel ADC channel number from the x-z-indices.
 
#define PIXEL_CH2X(c)   ((((c) >> 1U) ^ 0x07U) & 0x07U)
 Macro to determine the pixel x-index from the ADC channel number.
 
#define PIXEL_CH2Y(c)   ((((c) >> 3U) & 0x02U) | ((c) & 0x01U))
 Macro to determine the pixel y-index from the ADC channel number.
 
#define PIXEL_XY2N(x, y)   (((x) << 2U) | (y))
 Macro to determine the n-index from the x-y-indices.
 
#define PIXEL_N2X(n)   ((n) >> 2U)
 Macro to determine the pixel x-index from the n-index.
 
#define PIXEL_N2Y(n)   ((n) & 0x03U)
 Macro to determine the pixel y-index from the n-index.
 
#define PIXEL_N2CH(n)   ((((n) << 3U) & 0x10U) | ((((n) >> 1U) ^ 0x0EU) & 0x0EU) | ((n) & 0x01U))
 Macro to determine the pixel n-index from the ADC channel number.
 
#define PIXEL_CH2N(c)   (((((c) << 1U) ^ 0x1CU) & 0x1CU) | (((c) >> 3U) & 0x02U) | ((c) & 0x01U))
 Macro to determine the pixel.
 
#define PIXELN_MASK(n)   (0x01U << (n))
 Macro to create a pixel mask given by the pixels n-index.
 
#define PIXELN_ISENABLED(msk, n)   (((msk) >> (n)) & 0x01U)
 Macro to determine if a pixel given by the n-index is enabled in a pixel mask.
 
#define PIXELN_ENABLE(msk, n)   ((msk) |= (PIXELN_MASK(n)))
 Macro to enable a pixel given by the n-index in a pixel mask.
 
#define PIXELN_DISABLE(msk, n)   ((msk) &= (~PIXELN_MASK(n)))
 Macro disable a pixel given by the n-index in a pixel mask.
 
#define PIXELCH_MASK(c)   (0x01U << (PIXEL_CH2N(c)))
 Macro to create a pixel mask given by the pixels ADC channel number.
 
#define PIXELCH_ISENABLED(msk, c)   (PIXELN_ISENABLED(msk, PIXEL_CH2N(c)))
 Macro to determine if an ADC pixel channel is enabled from a pixel mask.
 
#define PIXELCH_ENABLE(msk, c)   (PIXELN_ENABLE(msk, PIXEL_CH2N(c)))
 Macro to enable an ADC pixel channel in a pixel mask.
 
#define PIXELCH_DISABLE(msk, c)   (PIXELN_DISABLE(msk, PIXEL_CH2N(c)))
 Macro to disable an ADC pixel channel in a pixel mask.
 
#define PIXELXY_MASK(x, y)   (0x01U << (PIXEL_XY2N(x, y)))
 Macro to create a pixel mask given by the pixel x-y-indices.
 
#define PIXELXY_ISENABLED(msk, x, y)   (PIXELN_ISENABLED(msk, PIXEL_XY2N(x, y)))
 Macro to determine if a pixel given by the x-y-indices is enabled in a pixel mask.
 
#define PIXELXY_ENABLE(msk, x, y)   (PIXELN_ENABLE(msk, PIXEL_XY2N(x, y)))
 Macro to enable a pixel given by the x-y-indices in a pixel mask.
 
#define PIXELXY_DISABLE(msk, x, y)   (PIXELN_DISABLE(msk, PIXEL_XY2N(x, y)))
 Macro disable a pixel given by the x-y-indices in a pixel mask.
 
#define CHANNELN_ISENABLED(msk, ch)   (((msk) >> ((ch) - 32U)) & 0x01U)
 Macro to determine if an ADC channel is enabled in a channel mask.
 
#define CHANNELN_ENABLE(msk, ch)   ((msk) |= (0x01U << ((ch) - 32U)))
 Macro to determine if an ADC channel is enabled in a channel mask.
 
#define CHANNELN_DISABLE(msk, ch)   ((msk) &= (~(0x01U << ((ch) - 32U))))
 Macro to determine if an ADC channel is disabled in a channel mask.
 
#define PIXEL_COUNT(pxmsk)   popcount(pxmsk)
 Macro to determine the number of enabled pixel/channels in a mask via a popcount algorithm.
 
#define CHANNEL_COUNT(pxmsk, chmsk)   (popcount(pxmsk) + popcount(chmsk))
 Macro to determine the number of enabled channels via a popcount algorithm.
 

Functions

static uint32_t ChannelToPixelMask (uint32_t msk)
 Converts a raw ADC channel mask to a x-y-sorted pixel mask.
 
static uint32_t PixelToChannelMask (uint32_t msk)
 Converts a x-y-sorted pixel mask to a raw ADC channel mask.
 
static uint32_t ShiftSelectedPixels (const uint32_t pixel_mask, const int8_t dx, const int8_t dy, const uint8_t center_y)
 Shifts a pixel mask by a given offset.
 
static uint32_t FillPixelMask (uint32_t pixel_mask, const uint8_t pixel_count, const uint8_t center_x, const uint8_t center_y)
 Fills a pixel mask to a specified number of pixels around a center pixel.
 
static uint32_t GetAdjacentPixelsMask (const uint_fast8_t x, const uint_fast8_t y)
 Fills a pixel mask with the direct neighboring pixels around a pixel.
 

Detailed Description

Pixel Channel Mapping.


The ADC Channels of each pixel or auxiliary channel on the device are numbered in a way that is convenient on the chip architecture. The macros in this module are defined in order to map between the chip internal channel number (ch) to the two-dimensional x-y-indices or one-dimensional n-index representation.

Macro Definition Documentation

◆ ARGUS_PIXELS

#define ARGUS_PIXELS   ((ARGUS_PIXELS_X)*(ARGUS_PIXELS_Y))

The total device pixel count.


◆ ARGUS_PIXELS_X

#define ARGUS_PIXELS_X   8

The device pixel field size in x direction (long edge).


◆ ARGUS_PIXELS_Y

#define ARGUS_PIXELS_Y   4

The device pixel field size in y direction (short edge).


◆ CHANNEL_COUNT

#define CHANNEL_COUNT (   pxmsk,
  chmsk 
)    (popcount(pxmsk) + popcount(chmsk))

Macro to determine the number of enabled channels via a popcount algorithm.


Parameters
pxmsk32-bit pixel mask
chmsk32-bit channel mask
Returns
The count of enabled ADC channels.

◆ CHANNELN_DISABLE

#define CHANNELN_DISABLE (   msk,
  ch 
)    ((msk) &= (~(0x01U << ((ch) - 32U))))

Macro to determine if an ADC channel is disabled in a channel mask.


Parameters
msk32-bit channel mask
chchannel number of the ADC channel to disable.

◆ CHANNELN_ENABLE

#define CHANNELN_ENABLE (   msk,
  ch 
)    ((msk) |= (0x01U << ((ch) - 32U)))

Macro to determine if an ADC channel is enabled in a channel mask.


Parameters
msk32-bit channel mask
chchannel number of the ADC channel to enabled.

◆ CHANNELN_ISENABLED

#define CHANNELN_ISENABLED (   msk,
  ch 
)    (((msk) >> ((ch) - 32U)) & 0x01U)

Macro to determine if an ADC channel is enabled in a channel mask.


Parameters
msk32-bit channel mask
chchannel number of the ADC channel.
Returns
True if the ADC channel is enabled.

◆ PIXEL_CH2N

#define PIXEL_CH2N (   c)    (((((c) << 1U) ^ 0x1CU) & 0x1CU) | (((c) >> 3U) & 0x02U) | ((c) & 0x01U))

Macro to determine the pixel.


Parameters
cThe ADC channel number of the pixel.
Returns
The n-index of the pixel.

◆ PIXEL_CH2X

#define PIXEL_CH2X (   c)    ((((c) >> 1U) ^ 0x07U) & 0x07U)

Macro to determine the pixel x-index from the ADC channel number.


Parameters
cThe ADC channel number of the pixel.
Returns
The x-index of the pixel.

◆ PIXEL_CH2Y

#define PIXEL_CH2Y (   c)    ((((c) >> 3U) & 0x02U) | ((c) & 0x01U))

Macro to determine the pixel y-index from the ADC channel number.


Parameters
cThe ADC channel number of the pixel.
Returns
The y-index of the pixel.

◆ PIXEL_COUNT

#define PIXEL_COUNT (   pxmsk)    popcount(pxmsk)

Macro to determine the number of enabled pixel/channels in a mask via a popcount algorithm.


Parameters
pxmsk32-bit pixel mask
Returns
The count of enabled pixel channels.

◆ PIXEL_N2CH

#define PIXEL_N2CH (   n)    ((((n) << 3U) & 0x10U) | ((((n) >> 1U) ^ 0x0EU) & 0x0EU) | ((n) & 0x01U))

Macro to determine the pixel n-index from the ADC channel number.


Parameters
nThe n-index of the pixel.
Returns
The ADC channel number of the pixel.

◆ PIXEL_N2X

#define PIXEL_N2X (   n)    ((n) >> 2U)

Macro to determine the pixel x-index from the n-index.


Parameters
nThe n-index of the pixel.
Returns
The x-index number of the pixel.

◆ PIXEL_N2Y

#define PIXEL_N2Y (   n)    ((n) & 0x03U)

Macro to determine the pixel y-index from the n-index.


Parameters
nThe n-index of the pixel.
Returns
The y-index number of the pixel.

◆ PIXEL_XY2CH

#define PIXEL_XY2CH (   x,
 
)    ((((y) << 3U) & 0x10U) | (((x) ^ 0x07U) << 1U) | ((y) & 0x01U))

Macro to determine the pixel ADC channel number from the x-z-indices.


Parameters
xThe x-index of the pixel.
yThe y-index of the pixel.
Returns
The ADC channel number of the pixel.

◆ PIXEL_XY2N

#define PIXEL_XY2N (   x,
 
)    (((x) << 2U) | (y))

Macro to determine the n-index from the x-y-indices.


Parameters
xThe x-index of the pixel.
yThe y-index of the pixel.
Returns
The n-index of the pixel.

◆ PIXELCH_DISABLE

#define PIXELCH_DISABLE (   msk,
 
)    (PIXELN_DISABLE(msk, PIXEL_CH2N(c)))

Macro to disable an ADC pixel channel in a pixel mask.


Parameters
mskThe 32-bit pixel mask
cThe pixel ADC channel number to disable.

◆ PIXELCH_ENABLE

#define PIXELCH_ENABLE (   msk,
 
)    (PIXELN_ENABLE(msk, PIXEL_CH2N(c)))

Macro to enable an ADC pixel channel in a pixel mask.


Parameters
mskThe 32-bit pixel mask
cThe pixel ADC channel number to enable.

◆ PIXELCH_ISENABLED

#define PIXELCH_ISENABLED (   msk,
 
)    (PIXELN_ISENABLED(msk, PIXEL_CH2N(c)))

Macro to determine if an ADC pixel channel is enabled from a pixel mask.


Parameters
mskThe 32-bit pixel mask
cThe ADC channel number of the pixel.
Returns
True if the specified pixel ADC channel is enabled.

◆ PIXELCH_MASK

#define PIXELCH_MASK (   c)    (0x01U << (PIXEL_CH2N(c)))

Macro to create a pixel mask given by the pixels ADC channel number.


Parameters
cThe ADC channel number of the pixel.
Returns
The 32-bit pixel mask with only pixel ADC channel set.

◆ PIXELN_DISABLE

#define PIXELN_DISABLE (   msk,
 
)    ((msk) &= (~PIXELN_MASK(n)))

Macro disable a pixel given by the n-index in a pixel mask.


Parameters
msk32-bit pixel mask
nn-index of the pixel to disable.

◆ PIXELN_ENABLE

#define PIXELN_ENABLE (   msk,
 
)    ((msk) |= (PIXELN_MASK(n)))

Macro to enable a pixel given by the n-index in a pixel mask.


Parameters
msk32-bit pixel mask
nn-index of the pixel to enable.

◆ PIXELN_ISENABLED

#define PIXELN_ISENABLED (   msk,
 
)    (((msk) >> (n)) & 0x01U)

Macro to determine if a pixel given by the n-index is enabled in a pixel mask.


Parameters
msk32-bit pixel mask
nn-index of the pixel.
Returns
True if the pixel (n) is enabled.

◆ PIXELN_MASK

#define PIXELN_MASK (   n)    (0x01U << (n))

Macro to create a pixel mask given by the pixels n-index.


Parameters
nn-index of the pixel.
Returns
The pixel mask with only n-index pixel set.

◆ PIXELXY_DISABLE

#define PIXELXY_DISABLE (   msk,
  x,
 
)    (PIXELN_DISABLE(msk, PIXEL_XY2N(x, y)))

Macro disable a pixel given by the x-y-indices in a pixel mask.


Parameters
msk32-bit pixel mask
xx-index of the pixel to disable.
yy-index of the pixel to disable.

◆ PIXELXY_ENABLE

#define PIXELXY_ENABLE (   msk,
  x,
 
)    (PIXELN_ENABLE(msk, PIXEL_XY2N(x, y)))

Macro to enable a pixel given by the x-y-indices in a pixel mask.


Parameters
msk32-bit pixel mask
xx-index of the pixel to enable.
yy-index of the pixel to enable.

◆ PIXELXY_ISENABLED

#define PIXELXY_ISENABLED (   msk,
  x,
 
)    (PIXELN_ISENABLED(msk, PIXEL_XY2N(x, y)))

Macro to determine if a pixel given by the x-y-indices is enabled in a pixel mask.


Parameters
msk32-bit pixel mask
xx-index of the pixel.
yy-index of the pixel.
Returns
True if the pixel (x,y) is enabled.

◆ PIXELXY_MASK

#define PIXELXY_MASK (   x,
 
)    (0x01U << (PIXEL_XY2N(x, y)))

Macro to create a pixel mask given by the pixel x-y-indices.


Parameters
xx-index of the pixel.
yy-index of the pixel.
Returns
The 32-bit pixel mask with only pixel ADC channel set.

Function Documentation

◆ ChannelToPixelMask()

static uint32_t ChannelToPixelMask ( uint32_t  msk)
inlinestatic

Converts a raw ADC channel mask to a x-y-sorted pixel mask.


Parameters
mskThe raw ADC channel mask to be converted.
Returns
The converted x-y-sorted pixel mask.

◆ FillPixelMask()

static uint32_t FillPixelMask ( uint32_t  pixel_mask,
const uint8_t  pixel_count,
const uint8_t  center_x,
const uint8_t  center_y 
)
inlinestatic

Fills a pixel mask to a specified number of pixels around a center pixel.


The pixel mask is iteratively filled with the nearest pixel to a specified center pixel until a specified number of pixels is achieved. The distance between two pixel is determined via a quadratic metric, i.e. dx^2 + dy^2. Pixels towards the lower x indices are preferred.

Note that the distance of only calculated approximately, e.g. the y distance of pixels is considered to be 2 instead of cos(60)*2.

Nothing is done if the number of pixels already exceeds the specified /p pixel_count parameter.

See also
Please also refer to the function Argus_GetCalibrationGoldenPixel to obtain the current Golden Pixel location.
Parameters
pixel_maskThe x-y-sorted pixel mask to be filled with pixels.
pixel_countThe final number of pixels in the pixel mask.
center_xThe center pixel x-index.
center_yThe center pixel y-index.
Returns
The filled pixel mask with at least /p pixel_count pixels selected.

◆ GetAdjacentPixelsMask()

static uint32_t GetAdjacentPixelsMask ( const uint_fast8_t  x,
const uint_fast8_t  y 
)
inlinestatic

Fills a pixel mask with the direct neighboring pixels around a pixel.


The pixel mask is iteratively filled with the direct neighbors of the specified center pixel.

Note that the function is able to handle corner and edge pixels and also to handle odd/even lines (which have different layouts)

Parameters
xThe selected pixel x-index.
yThe selected pixel y-index.
Returns
The filled pixel mask with all direct neighbors of the selected pixel.

◆ PixelToChannelMask()

static uint32_t PixelToChannelMask ( uint32_t  msk)
inlinestatic

Converts a x-y-sorted pixel mask to a raw ADC channel mask.


Parameters
mskThe x-y-sorted pixel channel mask to be converted.
Returns
The converted raw ADC channel mask.

◆ ShiftSelectedPixels()

static uint32_t ShiftSelectedPixels ( const uint32_t  pixel_mask,
const int8_t  dx,
const int8_t  dy,
const uint8_t  center_y 
)
inlinestatic

Shifts a pixel mask by a given offset.


This moves the selected pixel pattern by a specified number of pixels in x and y direction. If the shift in y direction is odd (e.g +1), the pattern will be shifted by +0.5 or -0.5 in x direction due to the hexagonal shape of the pixel field. Thus, a center pixel (usually the Golden Pixel) is determined that is used to determine if the pattern is shifted by +0.5 or -0.5 pixels in x direction. The center pixel is then always shifted without changing the x index and the surrounding pixels are adopting its x index accordingly.

Example: Consider the flower pattern, i.e. the Golden Pixel (e.g. 5/2) is selected and all is direct neighbors (i.e. 5/1, 6/1, 6/2, 6/3, 5/3, 4/2). If the pattern is shifted by -1 in y direction, the new Golden Pixel would be 5/1. Now all surrounding pixels are selected, namely 4/0, 4/1, 4/2, 5/0, 5/2, 6/1). This yields again the flower around the Golden Pixel.

Thus, the pixels can not all be shifted by the same dx/dy values due to the hexagonal shape of the pixel field, e.g. the upper right neighbor of 5/2 is 5/1 but the upper right neighbor of 5/1 is NOT 5/0 but 4/0! This happens only if the shift in y direction is an odd number. The algorithm to determine new indices is as follows:

  • If the shift in y direction is even (e.g. +2, -2), no compensation of the hexagonal shape is needed; skip compensation, simply add/subtract indices.
  • If the center pixel y index is even, pixels that will have even y index after the shift will be additionally shifted by -1 in x direction.
  • If the center pixel y index is odd, pixel that will have odd y index after the shift will be additionally shifted by +1 in x direction.
See also
Please also refer to the function Argus_GetCalibrationGoldenPixel to obtain the current Golden Pixel location.
Parameters
pixel_maskThe x-y-sorted pixel mask to be shifted.
dxThe number of pixel to shift in x direction.
dyThe number of pixel to shift in y direction.
center_yThe center y index of the pattern that is shifted.
Returns
The shifted pixel mask.