Basic Image AlgorithmS Library
2.8.0
|
class for detecting changes in image sequences More...
#include <Image/MixtureOfGaussians.hh>
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_ () |
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
Definition at line 71 of file MixtureOfGaussians.hh.
MixtureOfGaussians::MixtureOfGaussians | ( | const unsigned int | numDistributions, |
const unsigned int | sizeWindow = 3 , |
||
const float | updateFactor = 0.1 , |
||
const MoGColorModel | colorModel = MOG_NRGB |
||
) |
constructor
numDistributions | number of gaussian distributions for every pixel. |
sizeWindow | window size for calculation of covariance |
updateFactor | expectancy values get updated weighted with this factor. |
normalizeRGB. | normalize RGB input images to rgb. |
Definition at line 43 of file MixtureOfGaussians.cpp.
MixtureOfGaussians::~MixtureOfGaussians | ( | ) |
destructor
Definition at line 99 of file MixtureOfGaussians.cpp.
|
inline |
Definition at line 144 of file MixtureOfGaussians.hh.
int MixtureOfGaussians::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.
for MOG on HSLD give a three channel image with HSD
in | new image |
Definition at line 107 of file MixtureOfGaussians.cpp.
References BIAS::Erosion< InputStorageType, OutputStorageType >::Erode3Fast(), BIAS::Image< StorageType >::FillImageWithConstValue(), BIAS::Gauss< InputStorageType, OutputStorageType >::Filter(), BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::FileHandling::LeadingZeroString(), BIAS::TimeMeasure::Reset(), BIAS::ImageIO::Save(), BIAS::Gauss< InputStorageType, OutputStorageType >::SetHalfWinSize(), BIAS::Gauss< InputStorageType, OutputStorageType >::SetSigma(), BIAS::ImageBase::ST_unsignedchar, BIAS::TimeMeasure::Start(), and BIAS::TimeMeasure::Stop().
Referenced by BIAS::CylindricDepthTrackingPanorama::LoadPanorama(), and BIAS::ExampleMixtureOfGaussiansFrame::processImages_().
|
protected |
Definition at line 355 of file MixtureOfGaussians.cpp.
References BIAS::ImageConvert::ConvertST(), BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::MOG_HS, BIAS::MOG_HSD, BIAS::MOG_NRGB, BIAS::MOG_NRGBD, BIAS::MOG_RGB, BIAS::MOG_RGBD, and BIAS::ImageBase::ST_float.
|
inline |
Definition at line 148 of file MixtureOfGaussians.hh.
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.
int MixtureOfGaussians::GetCurrentDistributions | ( | std::vector< Image< float > > & | distributionImages | ) |
get vector of images containing current guesses (distributions)
Definition at line 327 of file MixtureOfGaussians.cpp.
int MixtureOfGaussians::GetDifferenceImage | ( | BIAS::Image< unsigned char > & | diff | ) |
get image of detected scene changes.
diff | scene changes encoded 0 for no change, 255 for change (grey values) |
Definition at line 257 of file MixtureOfGaussians.cpp.
int MixtureOfGaussians::GetDifferenceImageWithVisuals | ( | BIAS::Image< unsigned char > & | guiImage | ) |
get image of detected scene changes with visualisations of detection
guiImage | RGB Image with detected changes (white), bounding boxes (green), centers of mass (red), largest box (yellow) |
Definition at line 275 of file MixtureOfGaussians.cpp.
int MixtureOfGaussians::GetLargestBoundingBox | ( | BIAS::BIASBlob & | corners | ) |
get largest bounding box of detected changes
Definition at line 317 of file MixtureOfGaussians.cpp.
int MixtureOfGaussians::GetMatchValueImage | ( | BIAS::Image< float > & | match | ) |
Definition at line 243 of file MixtureOfGaussians.cpp.
int MixtureOfGaussians::GetMaxWeightImage | ( | BIAS::Image< float > & | weight | ) |
get image with current max weights, only interesting for visualisation
Definition at line 221 of file MixtureOfGaussians.cpp.
References BIAS::Image< StorageType >::FillImageWithConstValue(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::Image< StorageType >::Init(), BIAS::ImageBase::IsEmpty(), and BIAS::ImageBase::ST_float.
int MixtureOfGaussians::GetNormalizedImage | ( | BIAS::Image< float > & | normalized | ) |
get normalized rgb image
normalized | normalized rgb image (or unchanged grey image) |
Definition at line 207 of file MixtureOfGaussians.cpp.
int MixtureOfGaussians::GetWeightImage | ( | BIAS::Image< float > & | weights | ) |
get image with current weights and distributions
Definition at line 214 of file MixtureOfGaussians.cpp.
|
protected |
Definition at line 445 of file MixtureOfGaussians.cpp.
References BIAS::ImageBase::CM_Grey, BIAS::ImageBase::CM_RGB, BIAS::ImageBase::ST_float, and BIAS::ImageBase::ST_unsignedchar.
|
protected |
Definition at line 536 of file MixtureOfGaussians.cpp.
int MixtureOfGaussians::InitWeights | ( | const int | maxWeight, |
const int | minWeight, | ||
const float | errorMargin | ||
) |
init weights for background/object distinction
maxWeight | counter for how many times a pixel is matched can not exceed this maximum. this is decreased if a pixel is not matched. |
minWeight | a pixel matched minWeight times is considered background |
errorMargin | a 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().
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.
void MixtureOfGaussians::SetSmoothing | ( | const bool | smooth | ) |
Definition at line 78 of file MixtureOfGaussians.cpp.
Referenced by BIAS::CylindricDepthTrackingPanorama::CylindricDepthTrackingPanorama().
|
inline |
Definition at line 140 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 588 of file MixtureOfGaussians.cpp.
|
protected |
Definition at line 182 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 184 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 184 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 182 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 184 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 172 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 174 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 182 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 177 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 183 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 173 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 164 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 179 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 179 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 179 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 179 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 167 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 168 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 170 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 169 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 180 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 180 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 179 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 181 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 181 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 187 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 163 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 177 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 171 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 166 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 185 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 165 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 178 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 178 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 178 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 178 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 175 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 162 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 177 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 177 of file MixtureOfGaussians.hh.
|
protected |
Definition at line 161 of file MixtureOfGaussians.hh.