# Trial ::: haarcascade21 ::: [Reduction of overlapping ROIs]

Now that a decent Hit Rate has been achieved, the focus turns to reducing the False Alarms. One step to reducing the false alarms is to eliminate overlapping regions of interest, so that the false alarms picked up in about the same vicinity will count as 1 or 2 false alarms as opposed to 6 or 7.

Original False Alarm count was 95058, after some implementation on blocking out the suns disk the count drop to 79702.
This reduces the false alarms by 15356 which is about ≈ 16%.

ROIs before eliminating overlapping regions

ROIs after eliminating overlapping regions

Below is a coding excerpt for the function to eliminate regions of interest that overlap with other regions of interest. This is a very overly simple way of eliminating regions, this method could be extended to be more discriminating as well as smarter in its selection. The current method =, simply checks if the center point of a new region lies within the bounds of an already existing region.

```//!**************************************************
//! @details
//! This function is to determine if our new region of interest
//! overlaps any previous regions of interest in this image
//!
//! @param [in] <CvRect region>
//! The new region of interest in the image
//!
//! @return <bool bRegionOverlaps>
//! Boolean for whether this region overlaps a previous region of interest
//!**************************************************
bool DoRegionsOverlap(CvRect region)
{
bool bRegionOverlaps = false;
vector<CvRect>::iterator it;
for ( it = m_RegionsOfInterest.begin() ; it < m_RegionsOfInterest.end(); it++ )
{
//Is the center point contained in another region
int centerx = region.x + (region.width / 2);
int centery = region.y + (region.height / 2);

if (centerx >= it->x && centerx <= (it->x + it->width))
{
if (centery >= it->y && centery <= (it->y + it->height))
{
//TODO: Only keep the region that has the biggest area
bRegionOverlaps = true;
break;
}
}
}

return bRegionOverlaps;
}
```