示例#1
0
    Contour GetMaxContour() {
        if (!valid_) return Contour();

        double bestSize = -1;
        int bestIdx = -1;
        for (int i=0; i<contour_list_.size(); ++i)
            if (contour_list_[i].GetSize() > bestSize) {
                bestSize = contour_list_[i].GetSize();
                bestIdx = i;
            }

        if (bestIdx == -1) return Contour();
        return contour_list_[bestIdx];
    }
示例#2
0
文件: StructG.C 项目: citrit/ECSE4750
/*
void 
StructuredGrid::LoadLineCases() {

  for (int i=0;i<16;i++)
    for (int j=0;j<5;j++)
      lineCases[i].edges[j] = -1;
  lineCases[1].edges[0] = lineCases[2].edges[1] = lineCases[5].edges[0] = 
    lineCases[6].edges[1] = lineCases[9].edges[0] = lineCases[10].edges[1] = 
    lineCases[13].edges[0] = lineCases[14].edges[1] = 0;
  lineCases[1].edges[1] = lineCases[3].edges[1] = lineCases[5].edges[1] = 
    lineCases[7].edges[1] = lineCases[8].edges[0] = lineCases[10].edges[2] = 
    lineCases[12].edges[0] = lineCases[14].edges[0] = DimX;
  lineCases[4].edges[0] = lineCases[6].edges[0] = lineCases[7].edges[0] = 
    lineCases[8].edges[1] = lineCases[9].edges[1] = lineCases[10].edges[3] = 
    lineCases[11].edges[1] = DimX+1;
}
*/
void 
StructuredGrid::Render(Renderer *aren) {
  int i,j;

  if(Data == NULL) {
    DrawWhiteGrid(aren);
  }
  else {
    switch (CurMode) {
    case PLANE:
      DrawPlane(aren);
      break;
    case GRID:
      DrawColoredGrid(aren);
      break;
    case CONTOURS:
      Contour();
      CellSet::Render(aren);
      break;
    default:
      CellSet::Render(aren);
      break;
    }
  }
}
void exampleBigaus() { 

   int n = 100000;
   int nbins = 50;
   double xmin = -10; 
   double xmax = 10; 
   TH2 * h2 = new TH2D("h1","h2",nbins,xmin,xmax, nbins, xmin, xmax);
   // for the ROOT master and  6.07.06
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,7,6)   
   TF2 * f2 = new TF2("bigaus","bigaus");
#else
   // for older ROOT version
   TF2 * f2 = new TF2("bigaus",bigaus_function,xmin,xmax,xmin,xmax,6);
#endif

   f2->SetParameters(1,2,2,-1,3,0.3);

   h2->FillRandom("bigaus"); 

   f2->SetParameters(100,2,2,-1,3,0.3);

   h2->Fit("bigaus"); 

   h2->Draw("COLZ"); 

   // draw contours of fit result for sigmax and sigmay

   auto fitter = (TBackCompFitter *) TVirtualFitter::GetFitter();
   int par1 = 2; // index of sigmax
   int par2 = 4; // index of sigmax
   // make contour at desired CL
   double cl1 = 0.68;
   // make a contour with 80 points
   auto gr1 = new TGraph( 80 );
   fitter->Contour( par1, par2, gr1, cl1);
   new TCanvas(); 
   gr1->SetFillColor(42);
   auto gr2 = new TGraph( 80 );
   double cl2 = 0.95;
   fitter->Contour( par1, par2, gr2, cl2);
   gr2->SetFillColor(38);
   gr2->Draw("ALF"); 
   gr1->Draw("LF");
  

}
示例#4
0
    Contour GetBestContour(cv::Point point) {
        if (!valid_) return Contour();

        double bestDistance = std::numeric_limits<double>::max();
        int bestIdx = -1;
        for (int i=0; i<contour_list_.size(); ++i){
            // 只有面积大于某个阈值才会被认可 TODO
            if (contour_list_[i].GetSize() < 200) continue;
            cv::Point center = contour_list_[i].GetCenterPoint();
            double square_distance = (center.x - point.x)*(center.x - point.x) + (center.y - point.y)*(center.y - point.y);
            if (square_distance < bestDistance) {
                bestDistance = square_distance;
                bestIdx = i;
            }
        }
        
        if (bestIdx == -1) return Contour();
        return contour_list_[bestIdx];
    }
示例#5
0
ContourSeq*
sgContour( SurfaceGrid* sg, float contour_at ) {
	Contour(*sg, contour_at);
	
	ContourSeq* ret = globalseq;
	globalseq = 0;
	globalseqcurr = 0;

	return ret;
}
示例#6
0
int amain(void)
{
    Mat* image_array;
    Mat* Contour_out_image_array = new Mat[number_of_image];
    Mat* Cutting_image_array = new Mat[number_of_image];
    Mat* Resampled_image_array = new Mat[number_of_image];

    int i;
    int height=0;
    int width=0;
    int period=0;
    double Bounding_box_ratio[number_of_image];

    vector<Point> contour_point_array;
    vector<Point> refer_point;
    vector<vector<Point> > Segment;

    // Image_open;
    image_array = Image_open(number_of_image);

    // Loop
    for(i=1; i<number_of_image; i++)
    {
        // Cutting the silhouette area and Calculating the width&height ratio
        Cutting_image_array[i-1] = Cutting_silhouette_area(&image_array[i-1], &height, &width);
        Bounding_box_ratio[i-1] = (double)height/(double)width;

        // Contour extraction
        Contour_out_image_array[i-1] = Contour(&Cutting_image_array[i-1],&contour_point_array);

        // Resampling
        refer_point = Find_refer_point(contour_point_array);
        Segment = Resampling(&contour_point_array,&refer_point);
        Resampled_image_array[i-1] = Draw_Resampling(Segment,Contour_out_image_array[i-1]);

        imshow("Original", image_array[i-1]);
        waitKey(0);
        imshow("Cutting_image",Cutting_image_array[i-1]);
        waitKey(0);
        imshow("Contour_image",Contour_out_image_array[i-1]);
        waitKey(0);
        imshow("Resampling_image",Resampled_image_array[i-1]);
        waitKey(0);
    }

    Image_save(Resampled_image_array);
    //period = Gait_period_cal(number_of_image, Bounding_box_ratio);

    return 0;
}
示例#7
0
/**
 * Generate a set of contour lines to be draped on the terrain.
 *
 * \param fInterval  The vertical spacing between the contours.  For example,
 *		if the elevation range of your data is from 50 to 350 meters, then
 *		an fIterval of 100 will place contour bands at 100,200,300 meters.
 */
void ContourConverter::GenerateContours(float fInterval)
{
	float fMin, fMax;
	vtHeightField *hf = m_pHF;

	hf->GetHeightExtents(fMin, fMax);
	int start = (int) (fMin / fInterval) + 1;
	int stop = (int) (fMax / fInterval);

	SetQuikGridCallbackFunction(ReceiveContourPoint1, this);
	for (int i = start; i <= stop; i++)
	{
		m_fAltitude = i * fInterval;
		Contour(*m_pGrid, i * fInterval);
	}
}
示例#8
0
std::vector<Shape> LayoutContainer::GetShapes() {
	std::vector<Shape> shapes;
	
	{ // create the outline for this container
		Shape shape;
		shape.AddContour(Contour({glm::vec2(0.0f, 0.0f),
				glm::vec2(mWidth, 0.0f),
				glm::vec2(mWidth, mHeight),
				glm::vec2(0.0f, mHeight)}));
		shape.SetPosition(GetPosition(CoordinateSpace::Global));
		shape.SetDepth(-1.0f);
		shape.mRenderMode = GL_LINE_LOOP;
		
		// set colour depending on whether this is the root container or not
		if (mParent) {
			shape.SetColour(glm::vec3(1.0f, 0.0f, 1.0f));
		}
		else {
			shape.SetColour(glm::vec3(1.0f, 0.0f, 0.0f));
		}
		
		shapes.push_back(std::move(shape));
	}
	
	for (auto& container: mContainers) { // for all child containers...
		// recursively call GetShapes function
		std::vector<Shape> newShapes = container.GetShapes();
		shapes.insert(shapes.end(),
				newShapes.begin(), newShapes.end());
	}
	
	for (auto& division: mDivisions) { // for all child divisions...
		std::vector<Shape> newShapes = division.GetShapes();
		shapes.insert(shapes.end(),
				newShapes.begin(), newShapes.end());
	}
	
	return shapes;
}
示例#9
0
/**
 * Generate a set of contour lines to be draped on the terrain.
 *
 * \param fInterval  The vertical spacing between the contours.  For example,
 *		if the elevation range of your data is from 50 to 350 meters, then
 *		an fIterval of 100 will place contour bands at 100,200,300 meters.
 */
void vtContourConverter::GenerateContours(float fInterval)
{
	float fMin, fMax;
	vtHeightField *hf;
	if (m_pHF)
		hf = m_pHF;
	else
		hf = m_pTerrain->GetTiledGeom();
	if (!hf)
		return;

	hf->GetHeightExtents(fMin, fMax);
	int start = (int) (fMin / fInterval) + 1;
	int stop = (int) (fMax / fInterval);

	SetQuikGridCallbackFunction(ReceiveContourPoint2, this);
	for (int i = start; i <= stop; i++)
	{
		m_fAltitude = i * fInterval;
		Contour(*m_pGrid, i * fInterval);
	}
}
示例#10
0
/**
 * Generate a contour line to be draped on the terrain.
 *
 * \param fAlt The altitude (elevation) of the line to be generated.
 */
void ContourConverter::GenerateContour(float fAlt)
{
	SetQuikGridCallbackFunction(ReceiveContourPoint1, this);
	m_fAltitude = fAlt;
	Contour(*m_pGrid, fAlt);
}
std::vector < Contour > ContourDetector::detect(cv::Mat image)
{
	HSVImage hsv_image = HSVImage(image);
	cv::Mat hue_thresholded_lower;
	cv::Mat hue_thresholded_upper;
	cv::Mat hue_thresholded;
	cv::Mat saturation_thresholded_lower;
	cv::Mat saturation_thresholded_upper;
	cv::Mat saturation_thresholded;
	cv::Mat value_thresholded_lower;
	cv::Mat value_thresholded_upper;
	cv::Mat value_thresholded;
	cv::Mat threshold_out;
	cv::Mat blur_out;
	cv::Mat canny_out;
	cv::Mat processed_img;
	cv::threshold(hsv_image.hue, hue_thresholded_lower, params.min_hue, 255,
		      CV_THRESH_BINARY);
	cv::threshold(hsv_image.hue, hue_thresholded_upper, params.max_hue, 255,
		      CV_THRESH_BINARY_INV);
	hue_thresholded = hue_thresholded_lower & hue_thresholded_upper;
	cv::threshold(hsv_image.saturation, saturation_thresholded_lower,
		      params.min_saturation, 255, CV_THRESH_BINARY);
	cv::threshold(hsv_image.saturation, saturation_thresholded_upper,
		      params.max_saturation, 255, CV_THRESH_BINARY_INV);
	saturation_thresholded =
	    saturation_thresholded_lower & saturation_thresholded_upper;
	cv::threshold(hsv_image.value, value_thresholded_lower,
		      params.min_value, 255, CV_THRESH_BINARY);
	cv::threshold(hsv_image.value, value_thresholded_upper,
		      params.max_value, 255, CV_THRESH_BINARY_INV);
	value_thresholded = value_thresholded_lower & value_thresholded_upper;
	threshold_out = hue_thresholded.clone();
	if (params.filter_by_saturation)
		threshold_out = threshold_out & saturation_thresholded;
	if (params.filter_by_value)
		threshold_out = threshold_out & value_thresholded;
	if (params.filter_with_blur) {
		cv::Mat blur_tmp;
		cv::pyrDown(threshold_out, blur_tmp,
			    cv::Size(threshold_out.cols / 2,
				     threshold_out.rows / 2));
		cv::pyrUp(blur_tmp, blur_out, threshold_out.size());
	} else
		blur_out = threshold_out.clone();
	if (params.filter_with_canny) {
		cv::Canny(blur_out, canny_out, params.min_canny,
			  params.max_canny, 5);
		cv::dilate(canny_out, canny_out, cv::Mat(), cv::Point(-1, -1));
	} else
		canny_out = blur_out.clone();
	std::vector < std::vector < cv::Point > >all_contours_raw;
	cv::findContours(canny_out, all_contours_raw, CV_RETR_LIST,
			 CV_CHAIN_APPROX_SIMPLE);
	std::vector < Contour > all_contours;
	for (uint i = 0; i < all_contours_raw.size(); i++)
		all_contours.push_back(Contour(all_contours_raw.at(i)));
	std::vector < Contour > area_filtered_contours;
	if (params.filter_by_area) {
		for (uint i = 0; i < all_contours.size(); i++) {
			if (all_contours.at(i).get_area() > params.min_area
			    && area_filtered_contours.at(i).get_area() <
			    params.max_area)
				area_filtered_contours.push_back(all_contours.
								 at(i));
		}
	} else
		area_filtered_contours = all_contours;

	return area_filtered_contours;
}