Pixelwise Arithmetic Operations

Pixelwise arithmetic operations on 8-bit images. More...

Functions

int rapp_pixop_set_u8 (uint8_t *buf, int dim, int width, int height, unsigned value)
 Set all pixels to a constant value.
int rapp_pixop_not_u8 (uint8_t *buf, int dim, int width, int height)
 Negate all pixels.
int rapp_pixop_flip_u8 (uint8_t *buf, int dim, int width, int height)
 Flip the sign bit.
int rapp_pixop_lut_u8 (uint8_t *restrict buf, int dim, int width, int height, const uint8_t *restrict lut)
 Lookup-table transformation.
int rapp_pixop_abs_u8 (uint8_t *buf, int dim, int width, int height)
 Absolute value.
int rapp_pixop_addc_u8 (uint8_t *buf, int dim, int width, int height, int value)
 Add signed constant.
int rapp_pixop_lerpc_u8 (uint8_t *buf, int dim, int width, int height, unsigned value, unsigned alpha8)
 Linear interpolation with constant.
int rapp_pixop_lerpnc_u8 (uint8_t *buf, int dim, int width, int height, unsigned value, unsigned alpha8)
 Linear interpolation with a constant, rounded towards the constant value.
int rapp_pixop_copy_u8 (uint8_t *restrict dst, int dst_dim, const uint8_t *restrict src, int src_dim, int width, int height)
 Copy all pixels.
int rapp_pixop_add_u8 (uint8_t *restrict dst, int dst_dim, const uint8_t *restrict src, int src_dim, int width, int height)
 Saturated addition.
int rapp_pixop_avg_u8 (uint8_t *restrict dst, int dst_dim, const uint8_t *restrict src, int src_dim, int width, int height)
 Average value.
int rapp_pixop_sub_u8 (uint8_t *restrict dst, int dst_dim, const uint8_t *restrict src, int src_dim, int width, int height)
 Saturated subtraction.
int rapp_pixop_subh_u8 (uint8_t *restrict dst, int dst_dim, const uint8_t *restrict src, int src_dim, int width, int height)
 Halved subtraction.
int rapp_pixop_suba_u8 (uint8_t *restrict dst, int dst_dim, const uint8_t *restrict src, int src_dim, int width, int height)
 Absolute-value subtraction.
int rapp_pixop_lerp_u8 (uint8_t *restrict dst, int dst_dim, const uint8_t *restrict src, int src_dim, int width, int height, unsigned alpha8)
 Linear interpolation.
int rapp_pixop_lerpn_u8 (uint8_t *restrict dst, int dst_dim, const uint8_t *restrict src, int src_dim, int width, int height, unsigned alpha8)
 Linear interpolation with non-zero update, i.e., rounded towards src.
int rapp_pixop_lerpi_u8 (uint8_t *restrict dst, int dst_dim, const uint8_t *restrict src, int src_dim, int width, int height, unsigned alpha8)
 Linear interpolation with inverted second operand, or generalized subtraction.
int rapp_pixop_norm_u8 (uint8_t *restrict dst, int dst_dim, const uint8_t *restrict src, int src_dim, int width, int height)
 L1 norm.

Detailed Description

Pixelwise arithmetic operations on 8-bit images.

These functions operate in-place, i.e. the first operand is also the destination. All images must be aligned.

Next section: Thresholding


Function Documentation

int rapp_pixop_set_u8 ( uint8_t *  buf,
int  dim,
int  width,
int  height,
unsigned  value 
)

Set all pixels to a constant value.

Computes buf[i] = value.

Parameters:
[out] buf Pixel buffer pointer.
dim Pixel buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
value The value to set, in the range 0 – 0xff.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_not_u8 ( uint8_t *  buf,
int  dim,
int  width,
int  height 
)

Negate all pixels.

Computes buf[i] = 0xff - buf[i];

Parameters:
[in,out] buf Pixel buffer pointer.
dim Pixel buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_flip_u8 ( uint8_t *  buf,
int  dim,
int  width,
int  height 
)

Flip the sign bit.

It is equivalant to converting between the formats two's complement and unsigned with bias. Computes buf[i] = buf[i] ^ 0x80;

Parameters:
[in,out] buf Pixel buffer pointer.
dim Pixel buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_lut_u8 ( uint8_t *restrict  buf,
int  dim,
int  width,
int  height,
const uint8_t *restrict  lut 
)

Lookup-table transformation.

Computes buf[i] = lut[buf[i]].

Parameters:
[in,out] buf Pixel buffer pointer.
dim Pixel buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
lut The 8-bit lookup table to use, with at least 256 bytes. It may be misaligned.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_abs_u8 ( uint8_t *  buf,
int  dim,
int  width,
int  height 
)

Absolute value.

Computes 2*abs(buf[i] - 0x80). The result is saturated.

Parameters:
[in,out] buf Pixel buffer pointer.
dim Pixel buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_addc_u8 ( uint8_t *  buf,
int  dim,
int  width,
int  height,
int  value 
)

Add signed constant.

Computes buf[i] = buf[i] + value. The result is saturated.

Parameters:
[in,out] buf Pixel buffer pointer.
dim Pixel buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
value The value to add.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_lerpc_u8 ( uint8_t *  buf,
int  dim,
int  width,
int  height,
unsigned  value,
unsigned  alpha8 
)

Linear interpolation with constant.

Computes buf[i] += alpha8*(value - buf[i]), where the multiplication is a rounded 8-bit fixed-point multiply.

Parameters:
[in,out] buf Pixel buffer pointer.
dim Pixel buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
value The value to interpolate with, in the range 0 – 0xff.
alpha8 The Q.8 fixed-point blend factor, in the range 0 – 0x100.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_lerpnc_u8 ( uint8_t *  buf,
int  dim,
int  width,
int  height,
unsigned  value,
unsigned  alpha8 
)

Linear interpolation with a constant, rounded towards the constant value.

Computes buf[i] += alpha8*(value - buf[i]), where the multiplication is an 8-bit fixed-point multiply, rounded away from zero.

Parameters:
[in,out] buf Pixel buffer pointer.
dim Pixel buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
value The value to interpolate with, in the range 0 – 0xff.
alpha8 The Q.8 fixed-point blend factor, in the range 0 – 0x100.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_copy_u8 ( uint8_t *restrict  dst,
int  dst_dim,
const uint8_t *restrict  src,
int  src_dim,
int  width,
int  height 
)

Copy all pixels.

Computes dst[i] = src[i].

Parameters:
[out] dst Destination buffer pointer.
dst_dim Destination buffer row dimension in bytes.
[in] src Source buffer pointer.
src_dim Source buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_add_u8 ( uint8_t *restrict  dst,
int  dst_dim,
const uint8_t *restrict  src,
int  src_dim,
int  width,
int  height 
)

Saturated addition.

Computes dst[i] += src[i]. The result is saturated.

Parameters:
[in,out] dst Destination buffer pointer.
dst_dim Destination buffer row dimension in bytes.
[in] src Source buffer pointer.
src_dim Source buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_avg_u8 ( uint8_t *restrict  dst,
int  dst_dim,
const uint8_t *restrict  src,
int  src_dim,
int  width,
int  height 
)

Average value.

Computes dst[i] = (dst[i] + src[i] + 1) / 2.

Parameters:
[in,out] dst Destination buffer pointer.
dst_dim Destination buffer row dimension in bytes.
[in] src Source buffer pointer.
src_dim Source buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_sub_u8 ( uint8_t *restrict  dst,
int  dst_dim,
const uint8_t *restrict  src,
int  src_dim,
int  width,
int  height 
)

Saturated subtraction.

Computes dst[i] -= src[i]. The result is saturated.

Parameters:
[in,out] dst Destination buffer pointer.
dst_dim Destination buffer row dimension in bytes.
[in] src Source buffer pointer.
src_dim Source buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_subh_u8 ( uint8_t *restrict  dst,
int  dst_dim,
const uint8_t *restrict  src,
int  src_dim,
int  width,
int  height 
)

Halved subtraction.

Computes dst[i] = (dst[i] - src[i] + 0x100) / 2.

Parameters:
[in,out] dst Destination buffer pointer.
dst_dim Destination buffer row dimension in bytes.
[in] src Source buffer pointer.
src_dim Source buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_suba_u8 ( uint8_t *restrict  dst,
int  dst_dim,
const uint8_t *restrict  src,
int  src_dim,
int  width,
int  height 
)

Absolute-value subtraction.

Computes dst[i] = abs(dst[i] - src[i]).

Parameters:
[in,out] dst Destination buffer pointer.
dst_dim Destination buffer row dimension in bytes.
[in] src Source buffer pointer.
src_dim Source buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_lerp_u8 ( uint8_t *restrict  dst,
int  dst_dim,
const uint8_t *restrict  src,
int  src_dim,
int  width,
int  height,
unsigned  alpha8 
)

Linear interpolation.

Computes dst[i] += alpha8*(src[i] - dst[i]), where the multiplication is a rounded 8-bit fixed-point multiply.

Parameters:
[in,out] dst Destination buffer pointer.
dst_dim Destination buffer row dimension in bytes.
[in] src Source buffer pointer.
src_dim Source buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
alpha8 The Q.8 fixed-point blend factor, in the range 0 – 0x100.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_lerpn_u8 ( uint8_t *restrict  dst,
int  dst_dim,
const uint8_t *restrict  src,
int  src_dim,
int  width,
int  height,
unsigned  alpha8 
)

Linear interpolation with non-zero update, i.e., rounded towards src.

Computes dst[i] += alpha8*(src[i] - dst[i]), where the multiplication is an 8-bit fixed-point multiply, rounded away from zero.

Parameters:
[in,out] dst Destination buffer pointer.
dst_dim Destination buffer row dimension in bytes.
[in] src Source buffer pointer.
src_dim Source buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
alpha8 The Q.8 fixed-point blend factor, in the range 0 – 0x100.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_lerpi_u8 ( uint8_t *restrict  dst,
int  dst_dim,
const uint8_t *restrict  src,
int  src_dim,
int  width,
int  height,
unsigned  alpha8 
)

Linear interpolation with inverted second operand, or generalized subtraction.

Computes dst[i] += alpha8*(0xff - src[i] - dst[i]), where the multiplication is a rounded 8-bit fixed-point multiply.

Parameters:
[in,out] dst Destination buffer pointer.
dst_dim Destination buffer row dimension in bytes.
[in] src Source buffer pointer.
src_dim Source buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
alpha8 The Q.8 fixed-point blend factor, in the range 0 – 0x100.
Returns:
A negative error code on error, zero otherwise.
int rapp_pixop_norm_u8 ( uint8_t *restrict  dst,
int  dst_dim,
const uint8_t *restrict  src,
int  src_dim,
int  width,
int  height 
)

L1 norm.

Computes dst[i] = (abs(dst[i]) + abs(src[i]) + 1) / 2.

Parameters:
[in,out] dst Destination buffer pointer.
dst_dim Destination buffer row dimension in bytes.
[in] src Source buffer pointer.
src_dim Source buffer row dimension in bytes.
width Image width in pixels.
height Image height in pixels.
Returns:
A negative error code on error, zero otherwise.

Generated on 1 Jun 2016 for RAPP by  doxygen 1.6.1