📄 omxippp_getspatialmoment_s64.c
字号:
/** * * * File Name: omxIPPP_GetSpatialMoment_S64.c * OpenMAX DL: v1.0.2 * Revision: 10586 * Date: Wednesday, March 5, 2008 * * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. * * * * Description : Image Statistical Routine - Returns nOrd by mOrd spatial moment * calculated by omxIP_Moments_U8_CxR() functions, beforehand. * */#include "omxtypes.h"#include "armOMX.h"#include "omxIP.h"#include "armCOMM.h"#include "armIP.h"/** * Function: omxIPPP_GetSpatialMoment_S64 (4.3.1.2.5) * * Description: * Returns nOrd by mOrd spatial moment calculated by the Moments_U8 function. * Places the scaled result into the memory pointed to by pValue. * * Input Arguments: * * nOrd, mOrd - moment specifiers * pState - pointer to the state structure * nChannel - specifies the desired image channel from which to extract the * spatial moment. For a C3 input image, the valid range is from * 0-2. For a C1 input image, the only valid value is 0. * roiOffset - offset in pixels of the ROI origin (top left corner) from * the image origin * scaleFactor - value of the scale factor * * Output Arguments: * * pValue -pointer to the computed moment value * * Return Value: * * OMX_Sts_NoErr - no error * OMX_Sts_BadArgErr - bad arguments detected; at least one of the * following is true: * - pState or pValue is NULL * - nChannel contains an invalid channel number * OMX_StsIPPP_ContextMatchErr - contents of the implementation-specific * structure OMXMomentState are invalid * */OMXResult omxIPPP_GetSpatialMoment_S64( const OMXMomentState *pState, OMX_INT mOrd, OMX_INT nOrd, OMX_INT nChannel, OMXPoint roiOffset, OMX_S64* pValue, OMX_INT scaleFactor ){ OMX_INT xOff = roiOffset.x, yOff = roiOffset.y; OMX_INT i, j; ARMIPPP_MomentState *pMomentState = (ARMIPPP_MomentState *)pState; armRetArgErrIf(!pMomentState, OMX_Sts_BadArgErr); armRetArgErrIf(!pValue, OMX_Sts_BadArgErr); armRetArgErrIf((nChannel < 0) || (nChannel > 2) || (nChannel > pMomentState->maxValidChannel), OMX_Sts_BadArgErr); armRetArgErrIf((mOrd < 0) || (mOrd > ARM_IPPP_MOMENTS_MAX_ORDER-1), OMX_Sts_BadArgErr); armRetArgErrIf((nOrd < 0) || (nOrd > ARM_IPPP_MOMENTS_MAX_ORDER-1), OMX_Sts_BadArgErr); if((xOff == 0) && (yOff == 0)) { *pValue = pMomentState->spMoments[nChannel][mOrd][nOrd]; *pValue = armSatRoundLeftShift_S64(*pValue, -scaleFactor); return OMX_Sts_NoErr; } /** ---------------------------------------------------------------------------------- To compute the moments for non-zero offsets (xOff,yOff), we'll have to solve M(p,q,xOff,yOff) = Sum_(x,y)_of [(x-xOff)^p * (y-yOff)^q * f(x,y)] To solve this, we expand the first two factors using binomial expansion (with 0 <= p,q <= 4) and then multiply them to get a series of Terms as in, M(p,q,xOff,yOff) = Sum_(x,y)_of [(T1+T2+T3+...+T16) * f(x,y)] On expanding, this equation becomes M(p,q,xOff,yOff) = Sum_(x,y)_of [T1 * f(x,y)] + ... + Sum_(x,y)_of [T16 * f(x,y)] where, each Term Tn is a factor of (a power of x, a power of y and a constant). If we pull the constant out of each summation, each of the 16 terms of the moments equation M(p,q,xOff,yOff) can be written as: (constant * moment of some order). This idea is implemented in the following code, where (1) Firstly, we compute the terms Tn, which are nothing but binomial coefficients of the moments equation for the given order (p,q). (2) Then, multiply each coefficient with its corresponding moment value and continue to accumulate, until we're done with all of them. ---------------------------------------------------------------------------------- */ for(i = 0, *pValue = 0; i <= mOrd; i++) { for(j = 0; j <= nOrd; j++) { *pValue += (pMomentState->spMoments[nChannel][i][j] * armIPPP_ComputeBinomialCoeff(mOrd, nOrd, i, j, -xOff, -yOff)); } } *pValue = armSatRoundLeftShift_S64(*pValue, -scaleFactor); return OMX_Sts_NoErr;}/* End of file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -