BoundingBox GeometryManager<Geometry,GlobalOrdinal>::localBoundingBox() const
{
    double global_x_min = Teuchos::ScalarTraits<double>::rmax();
    double global_y_min = Teuchos::ScalarTraits<double>::rmax();
    double global_z_min = Teuchos::ScalarTraits<double>::rmax();
    double global_x_max = -Teuchos::ScalarTraits<double>::rmax();
    double global_y_max = -Teuchos::ScalarTraits<double>::rmax();
    double global_z_max = -Teuchos::ScalarTraits<double>::rmax();

    // Get the local bounding boxes compute the local bounding box.
    BoundingBox local_box;
    Teuchos::Tuple<double,6> box_bounds;
    Teuchos::Array<BoundingBox> boxes = boundingBoxes();
    Teuchos::Array<BoundingBox>::const_iterator box_iterator;
    DTK_CHECK( !boxes.empty() );
    for ( box_iterator = boxes.begin();
	  box_iterator != boxes.end();
	  ++box_iterator )
    {
	box_bounds = box_iterator->getBounds();

	if ( box_bounds[0] < global_x_min )
	{
	    global_x_min = box_bounds[0];
	}
	if ( box_bounds[1] < global_y_min )
	{
	    global_y_min = box_bounds[1];
	}
	if ( box_bounds[2] < global_z_min )
	{
	    global_z_min = box_bounds[2];
	}
	if ( box_bounds[3] > global_x_max )
	{
	    global_x_max = box_bounds[3];
	}
	if ( box_bounds[4] > global_y_max )
	{
	    global_y_max = box_bounds[4];
	}
	if ( box_bounds[5] > global_z_max )
	{
	    global_z_max = box_bounds[5];
	}
    }

    return BoundingBox( global_x_min, global_y_min, global_z_min,
			global_x_max, global_y_max, global_z_max );
}
Exemple #2
0
BBFind::Rectangles BBFind::placePotentialBoxes(const Map3 fullMap)
{
   // Takes in a map of distances to edges and greedily places
   // a potential box at every local maximum. Because the distance
   // map is clipped, this should place numerous small boxes
   // inside the center of detected objects above the minimum size.
   // These boxes are later merged to form a single larger
   // bounding box for each object.

   int numCategories = fullMap.size();
	int mapWidth = fullMap[0][0].size();
	int mapHeight = fullMap[0].size();
	float val = 0.0f;
	float maxVal = 0.0f;
	Rectangles boundingBoxes(numCategories);

	const int stride = mBBGuessSize / 8;

   #ifdef PV_USE_OPENMP_THREADS
      #pragma omp parallel for
   #endif
   for(int c = 0; c < numCategories; c++)
   {
      Map2 distanceMap = applyThreshold(fullMap[c], mMinBlobSize);
      for(int y = 1; y < mapHeight-1; y+=stride)
		{
         for(int x = 1; x < mapWidth-1; x+=stride)
         {
				//Look at neighboring values to deduce if this is a local maximum
				maxVal = distanceMap[y][x];
				for(int i = -1; i <= 1; i++)
				{
					for(int j = -1; j <= 1; j++)
					{
						val = distanceMap[y+j][x+i];
						maxVal = val > maxVal ? val : maxVal;
					}
				}
				//If this was a local maximum, place a potential bounding box
				if(maxVal > 0 && maxVal == distanceMap[y][x])
				{
					boundingBoxes[c].push_back({x, y, mBBGuessSize, mBBGuessSize});
				}
			}
		}
	}

	return boundingBoxes;
}