IMG_errdif_bin_8


Detailed Description


Functions

void IMG_errdif_bin_8 (unsigned char *restrict errdif_data, int cols, int rows, short *restrict err_buf, unsigned char thresh)


Function Documentation

void IMG_errdif_bin_8 ( unsigned char *restrict  errdif_data,
int  cols,
int  rows,
short *restrict  err_buf,
unsigned char  thresh 
)

Description:
The code implements the Binary Floyd-Steinberg error diffusion filter. The filter kernel used is illustrated below:
 
                                   +---+                                 
                                 P | 7 |                                 
                           +---+---+---+                                 
                           | 3 | 5 | 1 |                                 
                           +---+---+---+                                 
   
Pixels are processed from left-to-right, top-to-bottom. Each pixel is compared against a user-defined threshold. Pixels that are larger than the threshold are set to 255, and pixels that are smaller or equal to the threshold are set to 0. The error value for the pixel (eg. the difference between the thresholded pixel and its original grey level) is propagated to the neighboring pixels according to the filter above. This error propagation diffuses the error over a larger area, hence the term "error diffusion."
Parameters:
errdif_data Pointer to an input/output image
cols Number of columns (Width)
rows Number of rows (Height)
err_buf Row-to-row error buffer
thresh Threshold in range [0x00, 0xFF]
Algorithm:
The processing of the filter itself is inverted so that the errors from previous pixels "propagate into" a given pixel at the time the pixel is processed, rather than "accumulate into" a pixel as its neighbors are processed. This allows us to keep our image as an 8-bit image, and reduces the number of accesses to the image array. The inverted filter kernel performs identically to the kernel's original form. In this form, the weights specify the weighting assigned to the errors coming from the neighboring pixels.
 
                           +---+---+---+                           
                           | 1 | 5 | 3 |                           
                           +---+---+---+                           
                           | 7 | P                                 
                           +---+                                   
   
Assumptions:
  • "err_buf" must be initialized to zeros for the first call and the returned err_buf should be used for any subsequent calls
  • The size of "err_buf" should be (cols+1) bytes
Implementation Notes:
  • This code is fully interruptible
  • This code is compatible with C66x processors
  • This code is endian neutral
Benchmarks:
See IMGLIB_Test_Report.html for cycle and memory information.


Copyright 2012, Texas Instruments Incorporated