GaussBackground.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#pragma once
25
26
27// IVT
28#include "Image/ByteImage.h"
29#include "Math/FloatVector.h"
30#include "Math/Math2d.h"
31
32// C
33#include <math.h>
34
35// probability distribution of a pixel in HS-space
37{
38 Vec2d vMean; // mean of the distribution
39 Mat2d mCovariance; // inverse covariance matrix of the distribution (Sigma^-1)
40
41 bool bShifted; // true if H-scale has been shifted by 128
42 // to avoid overflow problems
43 float fSatWeight; // weighting for the use of S-dist only vs HS-dist
44};
45
46// class for learning, representation and segmentation of a background using
47// a normal distribution in HS-space
49{
50public:
51 CGaussBackground(const int nWidth, const int nHeight);
53
54 void LearnBackgroundRGB(CByteImage** pRGBImages, const int nNumImages);
55 void LearnBackground(CByteImage** pHSVImages, const int nNumImages);
56
57 void GetBinaryForegroundImageRGB(const CByteImage* pInputImageRGB,
58 CByteImage* pForegroundImage);
59
60 void SegmentImageRGB(const CByteImage* pInputImageRGB, CByteImage* pProbabilityImage);
61 void SegmentImageRGB(const CByteImage* pInputImageRGB, float* pProbabilityImage);
62 void SegmentImage(const CByteImage* pInputImageRGB,
63 const CByteImage* pInputImageHSV,
64 CByteImage* pProbabilityImage);
65 void SegmentImage(const CByteImage* pInputImageRGB,
66 const CByteImage* pInputImageHSV,
67 float* pProbabilityImage);
68
69 void BinarizeAndFillHoles(CByteImage* pProbabilityImage);
70
71private:
72 inline void FillHolesHorVert(const CByteImage* pInputImage,
73 CByteImage* pOutputImage,
74 const int nRadius = 20);
75 inline void
76 FillHolesDiag(const CByteImage* pInputImage, CByteImage* pOutputImage, const int nRadius = 20);
77 inline void FillHolesHorVertDiag(const CByteImage* pInputImage,
78 CByteImage* pOutputImage,
79 const int nRadius = 55);
80 inline double CalcProbOfPixel(const int nIndex, const Vec2d vHS_Value);
81
82 CPixelProbabilityDistribution* m_pPixelProbabilityDistributions;
83 int m_nImageWidth, m_nImageHeight;
84
85 CByteImage* m_pBackgroundRGB;
86};
void SegmentImage(const CByteImage *pInputImageRGB, const CByteImage *pInputImageHSV, CByteImage *pProbabilityImage)
CGaussBackground(const int nWidth, const int nHeight)
void LearnBackground(CByteImage **pHSVImages, const int nNumImages)
void SegmentImageRGB(const CByteImage *pInputImageRGB, CByteImage *pProbabilityImage)
void GetBinaryForegroundImageRGB(const CByteImage *pInputImageRGB, CByteImage *pForegroundImage)
void BinarizeAndFillHoles(CByteImage *pProbabilityImage)
void LearnBackgroundRGB(CByteImage **pRGBImages, const int nNumImages)