bool Hedcut::build(cv::Mat & input_image, int n) { cv::Mat input_GRAY; // YJ cvtColor(InputArrary src, OutputArray dst, int code, int dstCn = 0); cv::cvtColor(input_image, input_GRAY, CV_RGB2GRAY); //start = clock(); //sample n points std::vector<cv::Point2d> pts; sample_initial_points(input_GRAY, n, pts); //initialize cvt CVT cvt; cvt.iteration_limit = this->cvt_iteration_limit; cvt.max_site_displacement = this->max_site_displacement; cvt.debug = this->debug; //compute weighted centroidal voronoi tessellation //finish = cvt.compute_weighted_cvt(input_image, pts); cvt.compute_weighted_cvt(input_GRAY, pts); //create disks create_disks(input_image, cvt); //finish = clock(); //elapsed_time = (finish - start) / (double)CLOCKS_PER_SEC; return true; }
bool Hedcut::build(cv::Mat & input_image, int n) { cv::Mat grayscale; cv::cvtColor(input_image, grayscale, CV_BGR2GRAY); //sample n points std::vector<cv::Point2d> pts; sample_initial_points(grayscale, n, pts); //initialize cvt CVT cvt; cvt.iteration_limit = this->cvt_iteration_limit; cvt.max_site_displacement = this->max_site_displacement; cvt.average_termination = this->average_termination; cvt.gpu = this->gpu; cvt.subpixels = this->subpixels; cvt.debug = this->debug; clock_t startTime, endTime; startTime = clock(); //compute weighted centroidal voronoi tessellation if (cvt.gpu) cvt.compute_weighted_cvt_GPU(input_image, pts); else cvt.compute_weighted_cvt(grayscale, pts); //***** endTime = clock(); std::cout << "Total time: "<< ((double)(endTime - startTime)) / CLOCKS_PER_SEC << std::endl; if (debug) cv::waitKey(); //create disks create_disks(input_image, cvt); return true; }