📄 omxippp_filtermedian_u8_c1r.c
字号:
/** * * File Name: omxIPPP_FilterMedian_U8_C1R.c * OpenMAX DL: v1.0.2 * Revision: 10586 * Date: Wednesday, March 5, 2008 * * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. * * * * Description: * This file contains module for single channel median filtering * */#include "omxtypes.h"#include "armOMX.h"#include "omxIP.h"#include "armIP.h"#include "armCOMM.h"/** * Function: omxIPPP_FilterMedian_U8_C1R (4.3.1.1.2) * * Description: * Performs median filtering of the ROI of the source image pointed to by * pSrc using the median filter of the size maskSize and location anchor, and * places the result into the ROI of the destination image pointed to by pDst. * * Input Arguments: * * pSrc - pointer to the source ROI * srcStep - distance in bytes between the starts of consecutive lines in * the source image * dstStep - distance in bytes between the starts of consecutive lines in * the destination image * roiSize - size of the source and destination ROI, in pixels * maskSize - size of the mask, in pixels; minimum size is 3x3; maximum * size is 31x31. * anchor - anchor cell specifying the mask alignment with respect to the * position of the input pixels * * Output Arguments: * * pDst - pointer to the destination ROI * * Return Value: * * OMX_Sts_NoErr - no errors detected * OMX_Sts_BadArgErr - bad arguments detected; at least one of the * following is true: * - pSrc or pDst is NULL * - srcStep or dstStep is less than or equal to zero * - roiSize has a field with zero or negative value. * - anchor specifies a point outside of the mask * - maskSize is out of range, i.e., smaller than 3x3 or larger than 31x31 * */OMXResult omxIPPP_FilterMedian_U8_C1R( const OMX_U8* pSrc, OMX_INT srcStep, OMX_U8* pDst, OMX_INT dstStep, OMXSize roiSize, OMXSize maskSize, OMXPoint anchor ){ OMX_INT width,height; OMX_INT maskWidth,maskHeight; OMX_INT maskLength,maskByTwo; OMX_INT ax,ay; OMX_INT i,j,m,n; OMX_U8 buffer[(ARM_IPPP_MAX_MASK_SIZE)*(ARM_IPPP_MAX_MASK_SIZE)]; OMX_U8 *pBuffer,temp; const OMX_U8 *pSrcTemp; /* Argument Check */ armRetArgErrIf(!pDst , OMX_Sts_BadArgErr) armRetArgErrIf(!pSrc , OMX_Sts_BadArgErr) armRetArgErrIf(srcStep <= 0, OMX_Sts_BadArgErr) armRetArgErrIf(dstStep <= 0, OMX_Sts_BadArgErr) armRetArgErrIf(roiSize.width <= 0, OMX_Sts_BadArgErr) armRetArgErrIf(roiSize.height <= 0, OMX_Sts_BadArgErr) armRetArgErrIf( (maskSize.width & 1) == 0 , OMX_Sts_BadArgErr) armRetArgErrIf( (maskSize.height & 1) == 0 , OMX_Sts_BadArgErr) armRetArgErrIf(maskSize.width > ARM_IPPP_MAX_MASK_SIZE, OMX_Sts_BadArgErr) armRetArgErrIf(maskSize.width < ARM_IPPP_MIN_MASK_SIZE, OMX_Sts_BadArgErr) armRetArgErrIf(maskSize.height > ARM_IPPP_MAX_MASK_SIZE, OMX_Sts_BadArgErr) armRetArgErrIf(maskSize.height < ARM_IPPP_MIN_MASK_SIZE, OMX_Sts_BadArgErr) armRetArgErrIf(anchor.x >= maskSize.width , OMX_Sts_BadArgErr) armRetArgErrIf(anchor.y >= maskSize.height, OMX_Sts_BadArgErr) armRetArgErrIf(anchor.x < 0, OMX_Sts_BadArgErr) armRetArgErrIf(anchor.y < 0, OMX_Sts_BadArgErr) /* Processing */ width = roiSize.width; height = roiSize.height; maskWidth = maskSize.width; maskHeight = maskSize.height; maskLength = maskWidth * maskHeight; maskByTwo = ((maskLength - 1)>>1); ax = anchor.x; ay = anchor.y; for(n = 0 ; n < height ; n++) { for(m = 0 ; m < width ; m++) { pSrcTemp = pSrc + m + ax + ay * srcStep; /*pSrc(m + ax,n + ay)*/ pBuffer = buffer; /* Populate the buffer */ for( j = 0; j < maskHeight ; j++) { for( i = 0; i < maskWidth ; i++) { pBuffer[i] = pSrcTemp[-i]; } pSrcTemp -= srcStep; pBuffer += maskWidth; } /* Sort the data in buffer */ for(i = 0 ; i <= maskByTwo ; i++) { for(j = 0; j < (maskLength - 1 - i); j++ ) { if(buffer[j+1] < buffer[j]) { temp = buffer[j]; buffer[j] = buffer[j+1]; buffer[j+1] = temp; } } } /* Store the Output */ pDst[m] = (OMX_U8)buffer[maskByTwo]; } pDst += dstStep; pSrc += srcStep; } return OMX_Sts_NoErr;}/*End of File*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -