- improved peak manager: less noisy peak new/lost
git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@475 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -46,7 +46,6 @@ namespace jay {
|
||||
, pbh(_pbh)
|
||||
, height_rel(_height_rel)
|
||||
, height_abs(_height_abs)
|
||||
, isValid(true)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -55,13 +54,37 @@ namespace jay {
|
||||
int pbh;
|
||||
float height_rel;
|
||||
float height_abs;
|
||||
bool isValid;
|
||||
|
||||
bool isInRange(const Peak &other)
|
||||
bool isInRange(const Peak &other) const
|
||||
{
|
||||
return (other.pos >= left()) and (other.pos <= right());
|
||||
}
|
||||
|
||||
bool isIntersect(const Peak &other) const
|
||||
{
|
||||
return (right() >= other.left()) and (other.right() >= left());
|
||||
}
|
||||
|
||||
void heightUpdate_rel(float const *pData, int length)
|
||||
{
|
||||
float newHeight = -100.f;
|
||||
for (int i=left(); i <= right(); i++)
|
||||
{
|
||||
newHeight = std::max(newHeight, pData[i]);
|
||||
}
|
||||
height_rel = newHeight;
|
||||
}
|
||||
|
||||
void heightUpdate_abs(float const *pData, int length)
|
||||
{
|
||||
float newHeight = -100.f;
|
||||
for (int i=left(); i <= right(); i++)
|
||||
{
|
||||
newHeight = std::max(newHeight, pData[i]);
|
||||
}
|
||||
height_abs = newHeight;
|
||||
}
|
||||
|
||||
bool makeBox(int pbh_min, int pbh_max, float const *pData, int length)
|
||||
{
|
||||
pbh = 0;
|
||||
@@ -124,7 +147,7 @@ namespace jay {
|
||||
return pbh > 0;
|
||||
}
|
||||
|
||||
const Peak& update(const Peak &other)
|
||||
const Peak& merge(const Peak &other)
|
||||
{
|
||||
float beta = 0.1f;
|
||||
float alpha = (1.f-beta);
|
||||
@@ -132,16 +155,15 @@ namespace jay {
|
||||
pbh = alpha*pbh + beta*other.pbh;
|
||||
height_rel = std::max(height_rel, other.height_rel);
|
||||
height_abs = std::max(height_abs, other.height_abs);
|
||||
isValid = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int left()
|
||||
int left() const
|
||||
{
|
||||
return pos - pbh;
|
||||
}
|
||||
|
||||
int right()
|
||||
int right() const
|
||||
{
|
||||
return pos + pbh;
|
||||
}
|
||||
@@ -215,7 +237,7 @@ namespace jay {
|
||||
int newn = 1;
|
||||
for (int i=0; i < (n-1); i++)
|
||||
{
|
||||
if (peaks[i].height_abs < peaks[i+1].height_abs)
|
||||
if (peaks[i].height_rel < peaks[i+1].height_rel)
|
||||
{
|
||||
Peak temp = peaks[i+1];
|
||||
peaks[i+1] = peaks[i];
|
||||
|
||||
Reference in New Issue
Block a user