Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 3/22/2024
Public
Document Table of Contents

ReduceBits

Reduces the bit resolution of an image.

Syntax

Case 1: Operation on data of the same source and destination bit depths

IppStatus ippiReduceBits_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize roiSize, int noise, IppiDitherType dtype, int levels, Ipp8u* pBuffer);

Supported values for mod:

8u_C1R 16u_C1R 16s_C1R
8u_C3R 16u_C3R 16s_C3R
8u_C4R 16u_C4R 16s_C4R

IppStatus ippiReduceBits_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize roiSize, int noise, IppiDitherType dtype, int levels, Ipp8u* pBuffer);

Supported values for mod:

8u_AC4R 16u_AC4R 16s_AC4R

Case 2: Operation on data of different source and destination bit depths

IppStatus ippiReduceBits_8u1u_C1R(const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep, int dstBitOffset, IppiSize roiSize, int noise, int seed, IppiDitherType dtype, Ipp8u threshold, Ipp8u* pBuffer);

IppStatus ippiReduceBits_<mod>(const Ipp<srcDatatype>* pSrc, int srcStep, Ipp<dstDatatype>* pDst, int dstStep, IppiSize roiSize, int noise, IppiDitherType dtype, int levels, Ipp8u* pBuffer);

Supported values for mod:

16u8u_C1R 16s8u_C1R 32f8u_C1R 32f16u_C1R 32f16s_C1R
16u8u_C3R 16s8u_C3R 32f8u_C3R 32f16u_C3R 32f16s_C3R
16u8u_C4R 16s8u_C4R 32f8u_C4R 32f16u_C4R 32f16s_C4R

IppStatus ippiReduceBits_<mod>(const Ipp<srcDatatype>* pSrc, int srcStep, Ipp<dstDatatype>* pDst, int dstStep, IppiSize roiSize, int noise, IppiDitherType dtype, int levels, Ipp8u* pBuffer);

Supported values for mod:

16u8u_AC4R 16s8u_AC4R 32f8u_AC4R 32f16u_AC4R 32f16s_AC4R

Include Files

ippcc.h

Domain Dependencies

Headers: ippcore.h, ippvm.h, ipps.h, ippi.h

Libraries: ippcore.lib, ippvm.lib, ipps.lib, ippi.lib

Parameters

pSrc

Pointer to the source image ROI.

srcStep

Distance in bytes between starts of consecutive lines in the source image.

pDst

Pointer to the destination image ROI.

dstStep

Distance in bytes between starts of consecutive lines in the destination image.

dstBitOffset

Offset (in bits) in the first byte of the destination image row.

roiSize

Size of the source and destination ROI in pixels.

noise

The number specifying the amount of noise added. This parameter is set as a percentage of range [0..100].

seed

The seed value used by the pseudo-random number generation, should be set to 0.

dtype

The type of dithering to be used. The following types are supported:

ippDitherNone

No dithering is done

ippDitherStucki

The Stucki's error diffusion dithering algorithm is used

ippDitherFS

The Floid-Steinberg error diffusion dithering algorithm is used

ippDitherJJN

The Jarvice-Judice-Ninke error diffusion dithering algorithm is used

ippDitherBayer

The Bayer's threshold dithering algorithm is used

levels

The number of output levels for halftoning (dithering); can be varied in the range [2..(1<< depth)], where depth is the bit depth of the destination image.

threshold

Threshold level for Stucki's dithering for the function ippiReduceBits_8u1u_C1R.

pBuffer

Pointer to the buffer for internal calculations. To compute the size of the buffer, use the ReduceBitsGetBufferSize function.

Description

This function operates with ROI (see Regions of Interest in Intel IPP).

This function reduces the number of intensity levels in each channel of the source image pSrc and places the results in respective channels of the destination image pDst. Note that for floating point source data type, RGB values must be in the range [0..1].

The levels parameter sets the resultant number of intensity levels in each channel of the destination image.

If the noise value is greater than 0, some random noise is added to the threshold level used in computations. The amplitude of the noise signal is specified by the noise parameter set as a percentage of the destination image luminance range. For the 4x4 ordered dithering mode, the threshold value is determined by the dither matrix used, whereas for the error diffusion dithering mode the input threshold is set as half of the range value, where

range = ((1<< depth) - 1)/(levels - 1)

and depth is the bit depth of the source image.

For floating-point data type, range = 1.0/(levels - 1).

8u to 1u conversion. Source image is converted to a bitonal image. The function ippiReduceBits_8u1u_C1R supports only one dithering algorithm - Stucki's error diffusion. The destination image has a 8u data type, where each byte represents eight consecutive pixels of the bitonal image (1 bit per pixel). In this case, additional parameter dstBitOffset is required to specify the start position of the destination ROI buffer.

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error.

ippStsNullPtrErr

Indicates an error condition if pSrc or pDst is NULL.

ippStsSizeErr

Indicates an error condition if roiSize has a field with a zero or negative value.

ippStsNoiseValErr

Indicates an error condition if noise has an illegal value.

ippStsDitherTypeErr

Indicates an error condition if the specified dithering type is not supported.

ippStsDitherLevelsErr

Indicates an error condition if levels value is out of admissible range.

ippStsMemAllocErr

Indicates an error condition if memory allocation fails.

See Also