📄 img_median_3x3.h64
字号:
;* ======================================================================== *;
;* TEXAS INSTRUMENTS, INC. *;
;* *;
;* IMGLIB DSP Image/Video Processing Library *;
;* *;
;* Release: Revision 1.04b *;
;* CVS Revision: 1.14 Thu Sep 11 18:42:51 2003 (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_median_3x3 *
* *
* REVISION DATE *
* 11-Sep-2003 *
* *
* USAGE *
* This routine is C-callable and can be called as: *
* *
* void IMG_median_3x3 *
* ( *
* const unsigned char *restrict i_data, /* Input image */ *
* int n, /* Length of input (or output) */ *
* unsigned char *restrict o_data /* Output image */ *
* ) *
* *
* DESCRIPTION *
* This kernel performs a 3x3 median filter operation on 8-bit *
* unsigned values. The median filter comes under the class *
* of non-linear signal processing algorithms. *
* *
* Rather than replace the grey level at a pixel by a weighted *
* average of the nine pixels including and surrounding it, the *
* grey level at each pixel is replaced by the median of the nine *
* values. The median of a set of nine numbers is the middle *
* element so that half of the elements in the list are larger and *
* half are smaller. Median filters remove the effects of extreme *
* values from data, such as salt and pepper noise, although using *
* a wide may result in unacceptable blurring of sharp edges in *
* the original image. *
* *
* C CODE *
* The following is a C code description of the algorithm without *
* restrictions. The optimized implementations may have *
* restrictions, as noted under the "ASSUMPTIONS" below. *
* *
* void IMG_median_3x3 *
* ( *
* const unsigned char *restrict i_data, *
* int n, *
* unsigned char *restrict o_data *
* ) *
* { *
* unsigned char c0h, c1h, c2h; /* "hi", columns 0..2 */ *
* unsigned char c0m, c1m, c2m; /* "mid", columns 0..2 */ *
* unsigned char c0l, c1l, c2l; /* "lo", columns 0..2 */ *
* unsigned char h_min; /* "min" */ *
* unsigned char m_mid; /* "mid" */ *
* unsigned char l_max; /* "max" */ *
* unsigned char m_h, m_l, t, out; *
* *
* int i; *
* *
* /* ---------------------------------------------------- */ *
* /* Start off with a well-defined initial state. */ *
* /* ---------------------------------------------------- */ *
* c1h = c2h = c1m = c2m = c1l = c2l = 127; *
* *
* /* ---------------------------------------------------- */ *
* /* Iterate over the input row. */ *
* /* ---------------------------------------------------- */ *
* for (i = 0; i < n; i++) *
* { *
* /* ------------------------------------------------ */ *
* /* Slide the two previous columns of sorted */ *
* /* pixels over by 1. */ *
* /* ------------------------------------------------ */ *
* c0h = c1h; c1h = c2h; *
* c0m = c1m; c1m = c2m; *
* c0l = c1l; c1l = c2l; *
* *
* /* ------------------------------------------------ */ *
* /* Load in a new column of pixels, and sort into */ *
* /* low, medium, high. */ *
* /* ------------------------------------------------ */ *
* c2h = i_data[i ]; *
* c2m = i_data[i + n]; *
* c2l = i_data[i + 2*n]; *
* *
* if (c2l > c2h) { t = c2l; c2l = c2h; c2h = t; } *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -