Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BIAS::MixtureOfGaussians< StorageType > Class Template Reference

class for detecting changes in image sequences More...

#include <Image/MixtureOfGaussians.hh>

+ Inheritance diagram for BIAS::MixtureOfGaussians< StorageType >:
+ Collaboration diagram for BIAS::MixtureOfGaussians< StorageType >:

Public Member Functions

void AllowCreationOfNewDistributions (bool allow)
 
int Apply (BIAS::Image< StorageType > &in)
 update calculations with new image the image has to be formatted correctly, e.g for MoG on HSL images give only the first 2 channels in the image. More...
 
void EnableCleanup (bool noise=false, bool holes=false, bool erosion=false)
 
int GetBoundingBoxes (std::vector< BIAS::BIASBlob > &corners)
 get vector of corners for each bounding box of detected changes More...
 
int GetCurrentDistributions (std::vector< Image< float > > &distributionImages)
 get vector of images containing current guesses (distributions) More...
 
int GetDifferenceImage (BIAS::Image< unsigned char > &diff)
 get image of detected scene changes. More...
 
int GetDifferenceImageWithVisuals (BIAS::Image< unsigned char > &guiImage)
 get image of detected scene changes with visualisations of detection More...
 
int GetLargestBoundingBox (BIAS::BIASBlob &corners)
 get largest bounding box of detected changes More...
 
int GetMatchValueImage (BIAS::Image< float > &match)
 
int GetMaxWeightImage (BIAS::Image< float > &weight)
 get image with current max weights, only interesting for visualisation More...
 
int GetNormalizedImage (BIAS::Image< float > &normalized)
 get normalized rgb image More...
 
int GetWeightImage (BIAS::Image< float > &weights)
 get image with current weights and distributions More...
 
int InitWeights (const int maxWeight, const int minWeight, const float errorMargin)
 init weights for background/object distinction More...
 
 MixtureOfGaussians (const unsigned int numDistributions, const unsigned int sizeWindow=3, const float updateFactor=0.1, const MoGColorModel colorModel=MOG_NRGB)
 constructor More...
 
void SetColorModel (MoGColorModel model)
 set the used color model note that the images have to be given in the correct model no conversion will take place. More...
 
void SetSmoothing (const bool smooth)
 
void SetUpdateFactor (float factor=0.1f)
 
 ~MixtureOfGaussians ()
 destructor More...
 

Protected Member Functions

int CreateNormalizedImage_ (const BIAS::Image< StorageType > &in, BIAS::Image< float > &out)
 
int Init_ ()
 
int InitOnePixel_ (unsigned int x, unsigned int y, unsigned int c, unsigned int distrib)
 
int Update_ ()
 

Protected Attributes

bool bAllowNewDistributionCreation_
 
bool bCleanUp_
 
bool bErosion_
 
bool bInited_
 
bool bInverseCleanup_
 
BIAS::BlobDetectorBFS
< unsigned char > 
blobDetector_
 
bool blobDetectorRan_
 
bool bSmooth_
 
unsigned int channels_
 
MoGColorModel colorModel_
 
std::vector< BIAS::BIASBlobcorners_
 
BIAS::Image< float > cov_
 
unsigned int dCurDistributions_
 
unsigned int dDistributions_
 
unsigned int dFrameCounter_
 
unsigned int dFrames_
 
BIAS::Image< unsigned char > difference_
 
BIAS::Image< unsigned char > differenceSave_
 
BIAS::Image< unsigned char > differenceSmooth_
 
BIAS::Image< unsigned char > differenceVisu_
 
unsigned int dMaxWeight_
 
unsigned int dMinWeight_
 
unsigned int dWindow_
 
float fError_
 
float fUpdateFactor_
 
pthread_mutex_t * guardimagemutex
 
BIAS::Image< float > guess_
 
unsigned int height_
 
BIAS::Image< unsigned char > marker
 
BIAS::Image< float > matchValueImage_
 
float maxDepth_
 
BIAS::Image< float > maxWeight_
 
unsigned int roiLRx_
 
unsigned int roiLRy_
 
unsigned int roiULx_
 
unsigned int roiULy_
 
BIAS::Gauss< unsigned char,
unsigned char > 
smoothResultFilter_
 
BIAS::Image< float > weight_
 
unsigned int width_
 
unsigned int workChannels_
 
BIAS::Image< float > workImage_
 

Detailed Description

template<class StorageType>
class BIAS::MixtureOfGaussians< StorageType >

class for detecting changes in image sequences

Automatically find and visualize changes in image sequences with a mixture of gaussians approach.

After initialization of the algorithm it is possible to detect moving objects in a static scene, where the static scene is described as a background image. Detection is done by calculating the expectancy value of each pixel in the next frame given more than one gaussian distribution for each pixel. If the expectancy is not matched, a change is detected.

This class has been tested on RGB images but should work on other color formats and grey value images. One and three color channels supported.

see also ExampleMixtureOfGaussiansFrame.cpp

Author
fkellner

Definition at line 71 of file MixtureOfGaussians.hh.

Constructor & Destructor Documentation

template<class StorageType >
MixtureOfGaussians::MixtureOfGaussians ( const unsigned int  numDistributions,
const unsigned int  sizeWindow = 3,
const float  updateFactor = 0.1,
const MoGColorModel  colorModel = MOG_NRGB 
)

constructor

Parameters
numDistributionsnumber of gaussian distributions for every pixel.
sizeWindowwindow size for calculation of covariance
updateFactorexpectancy values get updated weighted with this factor.
normalizeRGB.normalize RGB input images to rgb.

Definition at line 43 of file MixtureOfGaussians.cpp.

template<class StorageType >
MixtureOfGaussians::~MixtureOfGaussians ( )

destructor

Definition at line 99 of file MixtureOfGaussians.cpp.

Member Function Documentation

template<class StorageType>
void BIAS::MixtureOfGaussians< StorageType >::AllowCreationOfNewDistributions ( bool  allow)
inline

Definition at line 144 of file MixtureOfGaussians.hh.

template<class StorageType>
int MixtureOfGaussians::Apply ( BIAS::Image< StorageType > &  in)
template<class StorageType>
int MixtureOfGaussians::CreateNormalizedImage_ ( const BIAS::Image< StorageType > &  in,
BIAS::Image< float > &  out 
)
protected
template<class StorageType>
void BIAS::MixtureOfGaussians< StorageType >::EnableCleanup ( bool  noise = false,
bool  holes = false,
bool  erosion = false 
)
inline

Definition at line 148 of file MixtureOfGaussians.hh.

template<class StorageType >
int MixtureOfGaussians::GetBoundingBoxes ( std::vector< BIAS::BIASBlob > &  corners)

get vector of corners for each bounding box of detected changes

Definition at line 306 of file MixtureOfGaussians.cpp.

template<class StorageType >
int MixtureOfGaussians::GetCurrentDistributions ( std::vector< Image< float > > &  distributionImages)

get vector of images containing current guesses (distributions)

Definition at line 327 of file MixtureOfGaussians.cpp.

template<class StorageType >
int MixtureOfGaussians::GetDifferenceImage ( BIAS::Image< unsigned char > &  diff)

get image of detected scene changes.

Parameters
diffscene changes encoded 0 for no change, 255 for change (grey values)

Definition at line 257 of file MixtureOfGaussians.cpp.

template<class StorageType >
int MixtureOfGaussians::GetDifferenceImageWithVisuals ( BIAS::Image< unsigned char > &  guiImage)

get image of detected scene changes with visualisations of detection

Parameters
guiImageRGB Image with detected changes (white), bounding boxes (green), centers of mass (red), largest box (yellow)

Definition at line 275 of file MixtureOfGaussians.cpp.

template<class StorageType >
int MixtureOfGaussians::GetLargestBoundingBox ( BIAS::BIASBlob corners)

get largest bounding box of detected changes

Definition at line 317 of file MixtureOfGaussians.cpp.

template<class StorageType >
int MixtureOfGaussians::GetMatchValueImage ( BIAS::Image< float > &  match)

Definition at line 243 of file MixtureOfGaussians.cpp.

template<class StorageType >
int MixtureOfGaussians::GetMaxWeightImage ( BIAS::Image< float > &  weight)
template<class StorageType >
int MixtureOfGaussians::GetNormalizedImage ( BIAS::Image< float > &  normalized)

get normalized rgb image

Parameters
normalizednormalized rgb image (or unchanged grey image)

Definition at line 207 of file MixtureOfGaussians.cpp.

template<class StorageType >
int MixtureOfGaussians::GetWeightImage ( BIAS::Image< float > &  weights)

get image with current weights and distributions

Definition at line 214 of file MixtureOfGaussians.cpp.

template<class StorageType >
int MixtureOfGaussians::Init_ ( )
protected
template<class StorageType >
int MixtureOfGaussians::InitOnePixel_ ( unsigned int  x,
unsigned int  y,
unsigned int  c,
unsigned int  distrib 
)
protected

Definition at line 536 of file MixtureOfGaussians.cpp.

template<class StorageType >
int MixtureOfGaussians::InitWeights ( const int  maxWeight,
const int  minWeight,
const float  errorMargin 
)

init weights for background/object distinction

Parameters
maxWeightcounter for how many times a pixel is matched can not exceed this maximum. this is decreased if a pixel is not matched.
minWeighta pixel matched minWeight times is considered background
errorMargina pixel is matched if: pixelValue < errorMargin*errorMargin*expected value

Definition at line 88 of file MixtureOfGaussians.cpp.

Referenced by BIAS::CylindricDepthTrackingPanorama::CylindricDepthTrackingPanorama(), and BIAS::ExampleMixtureOfGaussiansFrame::ExampleMixtureOfGaussiansFrame().

template<class StorageType >
void MixtureOfGaussians::SetColorModel ( MoGColorModel  model)

set the used color model note that the images have to be given in the correct model no conversion will take place.

Definition at line 72 of file MixtureOfGaussians.cpp.

template<class StorageType >
void MixtureOfGaussians::SetSmoothing ( const bool  smooth)
template<class StorageType>
void BIAS::MixtureOfGaussians< StorageType >::SetUpdateFactor ( float  factor = 0.1f)
inline

Definition at line 140 of file MixtureOfGaussians.hh.

template<class StorageType >
int MixtureOfGaussians::Update_ ( )
protected

Definition at line 588 of file MixtureOfGaussians.cpp.

Member Data Documentation

template<class StorageType>
bool BIAS::MixtureOfGaussians< StorageType >::bAllowNewDistributionCreation_
protected

Definition at line 182 of file MixtureOfGaussians.hh.

template<class StorageType>
bool BIAS::MixtureOfGaussians< StorageType >::bCleanUp_
protected

Definition at line 184 of file MixtureOfGaussians.hh.

template<class StorageType>
bool BIAS::MixtureOfGaussians< StorageType >::bErosion_
protected

Definition at line 184 of file MixtureOfGaussians.hh.

template<class StorageType>
bool BIAS::MixtureOfGaussians< StorageType >::bInited_
protected

Definition at line 182 of file MixtureOfGaussians.hh.

template<class StorageType>
bool BIAS::MixtureOfGaussians< StorageType >::bInverseCleanup_
protected

Definition at line 184 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::BlobDetectorBFS<unsigned char> BIAS::MixtureOfGaussians< StorageType >::blobDetector_
protected

Definition at line 172 of file MixtureOfGaussians.hh.

template<class StorageType>
bool BIAS::MixtureOfGaussians< StorageType >::blobDetectorRan_
protected

Definition at line 174 of file MixtureOfGaussians.hh.

template<class StorageType>
bool BIAS::MixtureOfGaussians< StorageType >::bSmooth_
protected

Definition at line 182 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::channels_
protected

Definition at line 177 of file MixtureOfGaussians.hh.

template<class StorageType>
MoGColorModel BIAS::MixtureOfGaussians< StorageType >::colorModel_
protected

Definition at line 183 of file MixtureOfGaussians.hh.

template<class StorageType>
std::vector<BIAS::BIASBlob> BIAS::MixtureOfGaussians< StorageType >::corners_
protected

Definition at line 173 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<float> BIAS::MixtureOfGaussians< StorageType >::cov_
protected

Definition at line 164 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::dCurDistributions_
protected

Definition at line 179 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::dDistributions_
protected

Definition at line 179 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::dFrameCounter_
protected

Definition at line 179 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::dFrames_
protected

Definition at line 179 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<unsigned char> BIAS::MixtureOfGaussians< StorageType >::difference_
protected

Definition at line 167 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<unsigned char> BIAS::MixtureOfGaussians< StorageType >::differenceSave_
protected

Definition at line 168 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<unsigned char> BIAS::MixtureOfGaussians< StorageType >::differenceSmooth_
protected

Definition at line 170 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<unsigned char> BIAS::MixtureOfGaussians< StorageType >::differenceVisu_
protected

Definition at line 169 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::dMaxWeight_
protected

Definition at line 180 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::dMinWeight_
protected

Definition at line 180 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::dWindow_
protected

Definition at line 179 of file MixtureOfGaussians.hh.

template<class StorageType>
float BIAS::MixtureOfGaussians< StorageType >::fError_
protected

Definition at line 181 of file MixtureOfGaussians.hh.

template<class StorageType>
float BIAS::MixtureOfGaussians< StorageType >::fUpdateFactor_
protected

Definition at line 181 of file MixtureOfGaussians.hh.

template<class StorageType>
pthread_mutex_t* BIAS::MixtureOfGaussians< StorageType >::guardimagemutex
protected

Definition at line 187 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<float> BIAS::MixtureOfGaussians< StorageType >::guess_
protected

Definition at line 163 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::height_
protected

Definition at line 177 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<unsigned char> BIAS::MixtureOfGaussians< StorageType >::marker
protected

Definition at line 171 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<float> BIAS::MixtureOfGaussians< StorageType >::matchValueImage_
protected

Definition at line 166 of file MixtureOfGaussians.hh.

template<class StorageType>
float BIAS::MixtureOfGaussians< StorageType >::maxDepth_
protected

Definition at line 185 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<float> BIAS::MixtureOfGaussians< StorageType >::maxWeight_
protected

Definition at line 165 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::roiLRx_
protected

Definition at line 178 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::roiLRy_
protected

Definition at line 178 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::roiULx_
protected

Definition at line 178 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::roiULy_
protected

Definition at line 178 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Gauss<unsigned char, unsigned char> BIAS::MixtureOfGaussians< StorageType >::smoothResultFilter_
protected

Definition at line 175 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<float> BIAS::MixtureOfGaussians< StorageType >::weight_
protected

Definition at line 162 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::width_
protected

Definition at line 177 of file MixtureOfGaussians.hh.

template<class StorageType>
unsigned int BIAS::MixtureOfGaussians< StorageType >::workChannels_
protected

Definition at line 177 of file MixtureOfGaussians.hh.

template<class StorageType>
BIAS::Image<float> BIAS::MixtureOfGaussians< StorageType >::workImage_
protected

Definition at line 161 of file MixtureOfGaussians.hh.


The documentation for this class was generated from the following files: