📄 img_errdif_bin.h
字号:
/* ======================================================================== */
/* TEXAS INSTRUMENTS, INC. */
/* */
/* IMGLIB DSP Image/Video Processing Library */
/* */
/* Release: Revision 1.04b */
/* CVS Revision: 1.4 Sun Sep 29 03:32:20 2002 (UTC) */
/* Snapshot date: 23-Oct-2003 */
/* */
/* This library contains proprietary intellectual property of Texas */
/* Instruments, Inc. The library and its source code are protected by */
/* various copyrights, and portions may also be protected by patents or */
/* other legal protections. */
/* */
/* This software is licensed for use with Texas Instruments TMS320 */
/* family DSPs. This license was provided to you prior to installing */
/* the software. You may review this license by consulting the file */
/* TI_license.PDF which accompanies the files in this library. */
/* ------------------------------------------------------------------------ */
/* Copyright (C) 2003 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
/* ======================================================================== */
/* Assembler compatibility shim for assembling 4.30 and later code on */
/* tools prior to 4.30. */
/* ======================================================================== */
/* ======================================================================== */
/* End of assembler compatibility shim. */
/* ======================================================================== */
/* ======================================================================== */
/* TEXAS INSTRUMENTS, INC. */
/* */
/* NAME */
/* IMG_errdif_bin -- Binary Floyd-Steinberg Error Diffusion. */
/* */
/* REVISION DATE */
/* 23-May-2002 */
/* */
/* */
/* USAGE */
/* This routine is C callable, and has the following C prototype: */
/* */
/* void IMG_errdif_bin */
/* ( */
/* unsigned char *restrict errdif_data, */
/* int cols, */
/* int rows, */
/* short *restrict err_buf, */
/* unsigned char thresh */
/* ) */
/* */
/* errdif_data: Input/Output image ptr */
/* cols: Number of columns (Width). Must be >= 2. */
/* rows: Number of rows (Height) */
/* err_buf: Buffer where one row of errors is to be saved */
/* thresh: Threshold in the range [0x00, 0xFF] */
/* */
/* errdif_data[] is used for both input and output and the number */
/* of colums, cols, must be at least 2. No restriction on number */
/* of rows. */
/* */
/* err_buf[], additional buffer, should be provided with */
/* initialized to all-zero's for the first call with an image. */
/* The subsequent call with the same image should provide this */
/* kernel the returned err_buf The size of err_buf should be */
/* (cols+1)*Half-Word. */
/* */
/* DESCRIPTION */
/* The code implements the Binary Floyd-Steinberg error diffusion */
/* filter. The filter kernel used is this one: */
/* */
/* +---+ */
/* 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." */
/* */
/* The following C code illustrates the algorithm. The C code is */
/* a general implementation without restrictions. This version */
/* may have restriction as noted in the ASSUMPTIONS below. */
/* */
/* void IMG_errdif_bin */
/* ( */
/* unsigned char *restrict */
/* errdif_data, // Input/Output image ptr // */
/* int cols, // Number of columns (Width) // */
/* int rows, // Number of rows (Height) // */
/* short *restrict */
/* err_buf, // row-to-row error buffer. // */
/* unsigned char thresh // Threshold from [0x00, 0xFF] // */
/* ) */
/* { */
/* int x, i, y; // Loop counters // */
/* int F; // Current pixel value at [x,y] // */
/* int errA; // Error value at [x-1, y-1] // */
/* int errB; // Error value at [ x, y-1] // */
/* int errC; // Error value at [x+1, y-1] // */
/* int errE; // Error value at [x-1, y] // */
/* int errF; // Error value at [ x, y] // */
/* */
/* // --------------------------------------------------------- // */
/* // Step through rows of pixels. // */
/* // --------------------------------------------------------- // */
/* for (y = 0, i = 0; y < rows; y++) */
/* { */
/* // ------------------------------------------------------ // */
/* // Start off with our initial errors set to zero at // */
/* // the start of the line since we do not have any // */
/* // pixels to the left of the row. These error terms // */
/* // are maintained within the inner loop. // */
/* // ------------------------------------------------------ // */
/* errA = 0; errE = 0; */
/* errB = err_buf[0]; */
/* */
/* // ------------------------------------------------------ // */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -