📄 whitebalancer.h
字号:
//-----------------------------------------------------------------------------
// (c) 2002 by Basler Vision Technologies
// Section: Vision Components
// Project: BCAM
// $Header: WhiteBalancer.h, 6, 09.10.2002 19:13:32, Nebelung, H.$
//-----------------------------------------------------------------------------
/**
\file WhiteBalancer.h
*
* Interface of the CWhiteBalancer class
*
\brief CWhiteBalancer is used to perform an automatic white balance
*/
//-----------------------------------------------------------------------------
#if !defined(AFX_WHITEBALANCER_H__41A157D4_8D94_4355_8A09_C82A59B24CBD__INCLUDED_)
#define AFX_WHITEBALANCER_H__41A157D4_8D94_4355_8A09_C82A59B24CBD__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "bcam.h"
#include <math.h>
#pragma warning( disable: 4244 4995 )
//------------------------------------------------------------------------------
// class CWhiteBalancer
// Author:
// Date: 20.09.2002
//------------------------------------------------------------------------------
/**
* \brief Performs the white balance
*
*/
//------------------------------------------------------------------------------
class CWhiteBalancer
{
public:
CWhiteBalancer(CBcam& device );
void Init(int ub, int vr);
bool Next(PBYTE imgBuffer, const CSize& imgSize);
long GetVRValue() { return m_VR; }
long GetUBValue() { return m_UB; }
virtual ~CWhiteBalancer();
void GetMeans(PBYTE imgBuffer, const CSize& imgSize, double& meanr, double& meang, double& meanb);
long m_nIterations;
CBcam& m_Camera;
bool m_fBayerImage;
bool m_fConverged;
long m_VR;
long m_UB;
long m_Min;
long m_Max;
long m_bestUB;
long m_bestVR;
double m_minError;
protected:
static const int MAX_ITERATIONS;
class CBisection
{
long m_min;
long m_max;
long m_left;
long m_right;
static const double THRESH_HIT;
static const double THRESH_ACCEPT;
public:
CBisection() { Init(0, 100); };
void Init(long min, long max) {
m_min = min;
m_max = max;
m_left = min;
m_right = max;
}
bool Next(const int x, const double y, const double t, long& next) {
bool converged = false;
if ( fabs( t - y ) <= THRESH_HIT )
{
converged = true;
ATLTRACE("hit\n");
next = x;
return true;
}
if ( m_left >= m_right )
{
next = x;
converged = true;
long newLeft, newRight;
if ( fabs(y - t ) > THRESH_ACCEPT )
{
if ( t > y )
{
newLeft = x ;
newRight = newLeft + 0.25 * ( m_max - m_min );
if ( newRight > m_max )
newRight = m_max;
}
else
{
newLeft = x - 0.25 * ( m_max - m_min );
if ( newLeft < m_min )
newLeft = m_min;
newRight = x;
}
if ( newRight - newLeft > 1 )
{
next = 0.5 * ( m_left + m_right );
m_left = newLeft;
m_right = newRight;
return false;
}
}
return true;
}
if ( y < t )
m_left = x + 1;
else
m_right = x - 1;
next = 0.5 * ( m_left + m_right );
return converged;
}
};
CBisection m_VBisection;
CBisection m_UBisection;
};
#endif // !defined(AFX_WHITEBALANCER_H__41A157D4_8D94_4355_8A09_C82A59B24CBD__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -