📄 backgroundsubtraction.h
字号:
/**
@file backgroundSubtraction.h
@brief implementation of background subtraction (called by abs.c)
@author Ma Gengyu
*/
#ifndef BACKGROUND_SUBTRACTION_H
#define BACKGROUND_SUBTRACTION_H
#include "../include/ema.h"
#ifndef WIN32
#include <xdc/std.h>
#include <ti/xdais/dm/ividenc.h>
#endif
#include <string.h>
#include <stdio.h>
//////////////////////////////////////////////////////////////////////////
// Definition of final labelling result
/** Labeled as foreground pixel */
#define FOREPIXEL 250 // foreground pixel value before filling
/** Labeled as foreground region */
#define FOREGROUND 150 // after filling
/** Labeled as Theft pixel */
#define THEFTPIXEL 210
/** Labeled as theft region */
#define THEFT 110
/** Labeled as Shadow or foreground pixel */
#define GAPFORE 200
/** Labeled as shadow pixel */
#define SHADOWPIXEL 65
/** Labeled as shadow region */
#define SHADOW 64
/** Labeled as noise region */
#define SMALLNOISE 32
/** Labeled as background */
#define BACKGROUND 0
//////////////////////////////////////////////////////////////////////////
// scene type
/** Scene type as general */
#define GENERAL_SCN 0 // bin is 0000 0000
/** Scene type as dark scene */
#define DARK_SCN 1 // bin is 0000 0001
/** Scene type as close view */
#define CLOSE_SCN 2 // bin is 0000 0010
/** Threshold to classify close scene
if blob is bigger than this, it is a close view */
#define THR_CLOSE 1600
/** Threshold to classify dark scene
if average intensity is lower than this, it is dark scene */
#define THR_DARK 640
/** number of Gaussians in the pixel model */
#define K_MODELS 6
/** size of each gaussian model, in INT
information of a model is saved in a INT array of size 4
[0]: center of color
[1]: variance of color distribution
[2]: weight of this model
[3]: how INT has it beINT to the background*/
#define PMSIZE 4
typedef enum {
SCENE_BRIGHT_OR_DARK,
SCENE_FAR_OR_NEAR,
SCENE_DEFAULT,
SCENE_BLOB_SIZE
} Scene_Parameter;
/** _____________ */
#define MINMAXSWAP(x1,x2) ( (x1)>(x2) ? 0 : (t=(x1), (x1)=(x2), (x2)=t) )
#ifdef __cplusplus
extern "C" {
#endif
// Image Level
void ABS_BackgroundModeling(BYTE *lpimg, BYTE updatefactor);
/// remove shadow
void ABS_RemoveShadow(BYTE* lplabel, BYTE* lpdiff, BYTE* lpsharp);
/// estimate sharpness
void ABS_Sharpness(BYTE* lpdiff, BYTE* lpsharpness);
/// extract foreground
void ABS_ExtractForeground(BYTE *lpimg, BYTE* lplabel, BYTE* lpdiff, INT updatefactor);
/// extract foreground in specific region
void ABS_ExtractWithMask(BYTE *lpimg, BYTE* lplabel,BYTE* gradimg);
/// initial background model
void ABS_InitBackGround(BYTE* lpBack);
/// get background model info
void ABS_GetBackGround(INT sort, BYTE* lpbgimg, BYTE* lpweightimg);
/// compute constancy image
//void ABS_ComputeConstancy(BYTE* previmg, BYTE* curimg, BYTE* constimg);
void ABS_ComputeConstancy(signed char* diffimg, BYTE* constimg);
/// verify theft regions by constancy image
void ABS_VerifyTheftByConstancy(BYTE* labelimg, BYTE* constimg);
/// scene analyze, get BMedge image
void ABS_SceneAnalyze(BYTE* edgeimg);
/// set scene type and change paramters
void ABS_SetParameters(Scene_Parameter para, INT value);
/// allocate mem for background model
void ABS_Create(USHORT vw, USHORT vh);
/// release memory
void ABS_Release();
// Pixel Level Functions
/// initialize pixel color model
void Pixel_InitModel(BYTE g, INT** lpmodel, USHORT* totalweight);
/// update pixel color model
void Pixel_ModelUpdate(BYTE g, INT** lpmodel, USHORT* totalweight, INT updatefactor);
/// compare new pixel with background model and update the model
INT Pixel_Compare_Update(BYTE g, INT** lpmodel, USHORT* totalweight, INT updatefactor, BYTE* lpdiff, BYTE sensitivity);
/// compare new pixel with background model
INT Pixel_Compare(BYTE g, INT** lpmodel, USHORT* totalweight, BYTE sensitivity);
/// sort the gaussians in a pixel by order
void Pixel_UpdateSortByKey(INT** lpmodel, BYTE mi);
// other functions
/// smooth image with median filter
void smoothByMedian(BYTE* input, BYTE *output);
/// smooth label image with median filter
void smoothByMedian_Binary(BYTE* input, BYTE *output);
/// smooth image by removing dark pixels
void smoothUp(BYTE* input, BYTE *output);
/// smooth image by removing bright pixels
void smoothDown(BYTE* input, BYTE *output);
#ifdef __cplusplus
}
#endif
#endif // !defined(AFX_BGMODEL_H__EC778154_E819_49EA_B3E4_2B306F2939A8__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -