⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 img_median_3x3.h64

📁 dm642函数库
💻 H64
📖 第 1 页 / 共 2 页
字号:
*               if (c2l > c2m) { t = c2l; c2l = c2m; c2m = t; }             *
*               if (c2m > c2h) { t = c2m; c2m = c2h; c2h = t; }             *
*                                                                           *
*               /* ------------------------------------------------ */      *
*               /*  Find the minimum value of the "hi" terms.       */      *
*               /* ------------------------------------------------ */      *
*               h_min = c2h;                                                *
*               if (c1h < h_min) { h_min = c1h; }                           *
*               if (c0h < h_min) { h_min = c0h; }                           *
*                                                                           *
*               /* ------------------------------------------------ */      *
*               /*  Find the middle value of the "mid" terms.       */      *
*               /* ------------------------------------------------ */      *
*               m_l   = c0m;                                                *
*               m_mid = c1m;                                                *
*               m_h   = c2m;                                                *
*                                                                           *
*               if (m_l   > m_h  ) { t = m_l; m_l = m_h; m_h = t; }         *
*               if (m_l   > m_mid) { m_mid = m_l; }                         *
*               if (m_mid > m_h  ) { m_mid = m_h; }                         *
*                                                                           *
*               /* ------------------------------------------------ */      *
*               /*  Find the maximum value of the "lo" terms.       */      *
*               /* ------------------------------------------------ */      *
*               l_max = c2l;                                                *
*               if (c1l > l_max) { l_max = c1l; }                           *
*               if (c0l > l_max) { l_max = c0l; }                           *
*                                                                           *
*               /* ------------------------------------------------ */      *
*               /*  Find the middle value of "h_min", "m_mid",      */      *
*               /*  "l_max" into "out".                             */      *
*               /* ------------------------------------------------ */      *
*               out = m_mid;                                                *
*                                                                           *
*               if (h_min > l_max) { t=h_min; h_min = l_max; l_max=t; }     *
*               if (h_min > out  ) { out = h_min; }                         *
*               if (out   > l_max) { out = l_max; }                         *
*                                                                           *
*               /* ------------------------------------------------ */      *
*               /*  Store the resulting pixel.                      */      *
*               /* ------------------------------------------------ */      *
*               o_data[i] = out;                                            *
*           }                                                               *
*       }                                                                   *
*                                                                           *
*   TECHNIQUES                                                              *
*       This implementation uses an incremental sorting technique to        *
*       greatly reduce the number of compares and exchanges necessary       *
*       to sort the image pixels.                                           *
*                                                                           *
*       The main loop reads three new pixels from the input image each      *
*       iteration.  These three pixels form the right edge of the filter    *
*       mask.  The filter data from the previous iteration is "slid         *
*       over" by one pixel to form the complete 3x3 mask.                   *
*       For the first output pixel, two columns of input data outside the   *
*       input image are assumed to be all 127. See the C implementation for *
*       more details.                                                       *
*                                                                           *
*       As 3-pixel is read in from the image, the pixels are sorted,        *
*       resulting in a "lo", "medium" and "hi" pixel value for that         *
*       column.  The result is that the filter mask is sorted into          *
*       three rows -- a row of "minimums", a row of "middle values",        *
*       and a row of "maximums".                                            *
*                                                                           *
*       The median filter operates from this partially ordered mask.        *
*       It finds the smallest element in the row of "maximums",             *
*       the middle element in the row of "middle values", and               *
*       the largest element in the row of "minimums".  The median           *
*       value of these three values is the median for the entire 3x3        *
*       mask.                                                               *
*                                                                           *
*       This process minimizes compares, as the whole mask does not         *
*       need to be sorted between iterations.  Rather, the partial          *
*       ordering for two of the three columns from one iteration is         *
*       used directly for the next iteration.                               *
*                                                                           *
*                                                                           *
*   ASSUMPTIONS                                                             *
*       The length 'len' must be a multiple of four.                        *
*       No alignment is required.                                           *
*                                                                           *
*   MEMORY NOTE                                                             *
*       No bank conflicts occur.                                            *
*       No stack frame is used.                                             *
*       This is a LITTLE ENDIAN implementation.                             *
*                                                                           *
*   CYCLES                                                                  *
*       cycles = len * 2 + 32.                                              *
*                                                                           *
*       For len =  64, cycles = 160.                                        *
*       For len = 256, cycles = 544.                                        *
*                                                                           *
*   CODESIZE                                                                *
*       248 bytes                                                           *
*                                                                           *
*   BIBLIOGRAPHY                                                            *
*       Knuth, Donald E.  The_Art_of_Computer_Programming, Vol 3,           *
*           Pg. 180:  "Minimum Comparison Sorting."                         *
*                                                                           *
* ------------------------------------------------------------------------- *
*             Copyright (c) 2003 Texas Instruments, Incorporated.           *
*                            All Rights Reserved.                           *
* ========================================================================= *

        .global _IMG_median_3x3

* ========================================================================= *
*   End of file:  img_median_3x3.h64                                        *
* ------------------------------------------------------------------------- *
*             Copyright (c) 2003 Texas Instruments, Incorporated.           *
*                            All Rights Reserved.                           *
* ========================================================================= *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -