DCMTK Version 3.7.0 OFFIS DICOM Toolkit

Public Member Functions | Private Member Functions | Private Attributes | List of all members
DcmQuantFloydSteinberg Class Reference

this class implements Floyd-Steinberg error diffusion. More...

## Public Member Functions
| DcmQuantFloydSteinberg ()
| constructor
| ~DcmQuantFloydSteinberg ()
| destructor
OFCondition | initialize (unsigned long cols)
| initializes the Floyd-Steinberg error vectors for an image with the given number of columns. More...
void | adjust (DcmQuantPixel &px, long col, long maxval)
| uses the Floyd-Steinberg error vectors to adjust the color of the current image pixel. More...
void | propagate (const DcmQuantPixel &px, const DcmQuantPixel &mapped, long col)
| propagates the Floyd-Steinberg error terms for one pixel. More...
void | startRow (long &col, long &limitcol)
| starts error diffusion for a new row. More...
void | finishRow ()
| finishes error diffusion for one image row. More...
void | nextCol (long &col) const
| increases or decreases the column number depending on the direction flag. More...

## Private Member Functions
void | cleanup ()
| frees all memory allocated by the error vectors
| DcmQuantFloydSteinberg (const DcmQuantFloydSteinberg &src)
| private undefined copy constructor
DcmQuantFloydSteinberg & | operator= (const DcmQuantFloydSteinberg &src)
| private undefined copy assignment operator

## Private Attributes
long * | thisrerr
| current red error vector. Points to an array of (columns + 2) entries.
long * | nextrerr
| red error vector for next row. Points to an array of (columns + 2) entries.
long * | thisgerr
| current green error vector. Points to an array of (columns + 2) entries.
long * | nextgerr
| green error vector for next row. Points to an array of (columns + 2) entries.
long * | thisberr
| current blue error vector. Points to an array of (columns + 2) entries.
long * | nextberr
| blue error vector for next row. Points to an array of (columns + 2) entries.
long * | temperr
| temporary pointer used for swapping error vectors
int | fs_direction
| boolean flag indicating in which direction (left to right/right to left) the FS distribution should be done. More...
unsigned long | columns
| number of columns in image

## Detailed Description

this class implements Floyd-Steinberg error diffusion.

It is used during the color quantization of an image.

## Member Function Documentation

## ◆ adjust()

void DcmQuantFloydSteinberg::adjust | ( | DcmQuantPixel & | px,
|  | long | col,
|  | long | maxval
| ) |  |
| inline

uses the Floyd-Steinberg error vectors to adjust the color of the current image pixel.

Parameters

  px | the original image pixel is passed in this parameter. Upon return, the pixel value contains the new value after error diffusion.
  col | column in which the current pixel is located, must be [0..columns-1]
  maxval | maximum value for each color component.

References DcmQuantPixel::getBlue(), DcmQuantPixel::getGreen(), and DcmQuantPixel::getRed().

## ◆ finishRow()

void DcmQuantFloydSteinberg::finishRow | ( |  | ) |
| inline

finishes error diffusion for one image row.

The direction flag is inverted and the error vectors for the "current" and "next" image row are swapped.

## ◆ initialize()

OFCondition DcmQuantFloydSteinberg::initialize | ( | unsigned long | cols | ) |

initializes the Floyd-Steinberg error vectors for an image with the given number of columns.

Parameters

  cols | number of columns in image

Returns
  EC_Normal if successful, an error code otherwise.

## ◆ nextCol()

void DcmQuantFloydSteinberg::nextCol | ( | long & | col | ) | const
| inline

increases or decreases the column number depending on the direction flag.

Parameters

  col | column number, may become negative

## ◆ propagate()

void DcmQuantFloydSteinberg::propagate | ( | const DcmQuantPixel & | px,
|  | const DcmQuantPixel & | mapped,
|  | long | col
| ) |  |
| inline

propagates the Floyd-Steinberg error terms for one pixel.

Parameters

  px | color value the current image pixel should have (after adjustment)
  mapped | color value (selected from the color LUT) the current image pixel really uses
  col | column in which the current pixel is located, must be [0..columns-1]

## ◆ startRow()

void DcmQuantFloydSteinberg::startRow | ( | long & | col,
|  | long & | limitcol
| ) |  |
| inline

starts error diffusion for a new row.

The error vectors for the next image row are initialized to zero. The initial and last column of the current row are determined

Parameters

  col | initial column for the current row returned in this parameter
  limitcol | limit column (one past the last valid column) for the current row returned in this parameter. May become negative.

## Member Data Documentation

## ◆ fs_direction

int DcmQuantFloydSteinberg::fs_direction
| private

boolean flag indicating in which direction (left to right/right to left) the FS distribution should be done.

Flag is inverted after each row.

The documentation for this class was generated from the following file:

- dcmimage/include/dcmtk/dcmimage/diqtfs.h

Generated on Mon Dec 15 2025 for DCMTK Version 3.7.0 by Doxygen 1.9.1