This DEMO is provided for testing the algorithm published in "Image Partitioning into Convex Polygons. Duan L.Y., Lafarge F. CVPR15, Boston, US".

//=============================================================================
The usage is:
-h,--help: Show this help message
-input: give the filename of the input image
-output: give the output folder
-epsilon: the expected avarage radius of voronoi cells by pixel

//==============================================================================
Results are saved as following:
-save boundary: save boundary map of partition in a 'name.bmp' file with white pixels.
-save labels: save the multi-label segmentation result in a 'name.txt' file by rows. 
-voronoi PLY: save voronoi partition as PLY format.
-line-segs PLY: save detected line-segments as PLY format.
-Delaunay Triangulation: 'vertices' saved in '.vertex', and the relative polygon saved in '.polygon' with '.num' indicating the number of points of each polygon. An example of reading DT and polygons will be given at the end of this document.


//=============================================================================
Thanks for testing our method! Hope you enjoy it.



//=============================================================================
Example to read Delaunay Triangulation and the polyons:

bool readDT_fromFILE(
	const std::string & filenameNoEx, 
	Triangulation_D & DT, 
	int & width,
	int & height,
	double &eps)
{
	//// load triangle and vcell and seedtype if exist
	DT.clear();
	std::ifstream ifs(filenameNoEx+".vertex");
	std::ifstream ifsN(filenameNoEx+".num");
	std::ifstream ifsV(filenameNoEx+".polygon");
	if(ifs.fail() || ifsN.fail() || ifsV.fail())
	{
		std::cout<<red<<"Cannot load DT files.---> readDT_fromFILE"<<white<<std::endl;
		return false;
	}
	Point_2 p, vcp;
	int num(0);
	int count(0), test_count(0);
	Triangulation_D::Vertex_handle vh;
	ifs>>width; ifs>>height; ifs>>eps;
	while(ifs >> p) 
	{
		vh=DT.insert(p);
		vh->info().index=count;count++;
		
		if(ifsN>>num)
		{
			for(int i=0;i<num;i++)
			{
				if(ifsV>>vcp)
					vh->info().Vcell.push_back(vcp);
				else
					return false;
			}			

		}
		else return false;
	}		
	ifs.close();
	ifsN.close();
	ifsV.close();
	return true;
}


//=================================================================================
THE END