📄 emd_histogram.c
字号:
/*
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006-2008 Beijing, pengzhen (pengzhenxp@yahoo.com.cn) //
// //
///////////////////////////////////////////////////////////////////////////////
*/
#include "emd_histogram_upper_envelope.c"
#include "emd_histogram_lower_envelope.c"
static inline void get_all_histogram( HistogramContext* hc )
{
UINT *hist_mean = (UINT*)(hc->m_pMean ) ;
UINT *hist_residue = (UINT*)(hc->m_pResidue ) ;
UINT *hist_upper = (UINT*)hc->m_pUpper ;
UINT *hist_lower = (UINT*)hc->m_pLower ;
UINT *hist_data = (UINT*)hc->m_pHistogram ;
int i = HISTTOGRAM_COUNT ;
/* upper histogram */
get_upper_histogram( hc ) ;
/* lower histogram */
get_lower_histogram( hc ) ;
while( i-- )
{
// *hist_mean = *hist_lower ;
*hist_mean = ( (*hist_upper) + (*hist_lower) ) /2 ;
*hist_residue = (*hist_data) - (*hist_mean) ;
hist_mean ++ ; hist_residue ++; hist_data ++; hist_upper ++ ; hist_lower ++;
}
}
static inline void draw_all_histogram( HistogramContext* hc,
BYTE* data , int stride, int width, int height , int off )
{
/*draw histogram */
draw_histogram( 0x10, hc->m_pHistogram, data, stride, off,0, width-off*2,height-off*2 ) ;
/*draw upper histogram */
//draw_histogram( 0xf0, hc->m_pUpper, data, stride, off,0, width-off*2,height-off*2 ) ;
/*draw lower histogram */
//draw_histogram( 0x80, hc->m_pLower, data, stride, off,0, width-off*2,height-off*2 ) ;
/*draw mean histogram */
draw_histogram( 0xf0, hc->m_pMean, data, stride, off,0, width-off*2,height-off*2 ) ;
/*draw residue histogram */
draw_histogram( 0x80, hc->m_pResidue, data, stride, off,0, width-off*2,height-off*2 ) ;
}
int dvp_emd_analysis_histogram( dvp_ctx *dvpctx, void* data, int width, int height, int stride )
{
HistogramContext* hc = &(m_pHistogramContext) ;
/* histogram */
get_histogram( hc, data, width, height, stride ) ;
// get energy
energy_histogram( hc->m_pHistogram ) ;
#define Hist_H_Off height/8
/* norm histogram */
norm_histogram( hc->m_pHistogram, height-Hist_H_Off*2) ;
/* get histogram */
get_all_histogram( hc ) ;
/*draw histogram */
draw_all_histogram( hc, (BYTE*)data, stride, width, height , Hist_H_Off ) ;
#undef Hist_H_Off
return 1 ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -