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

//=============================================================================
Buttons in 'Setting' panel are explained as following:
-Select Input image: select an image file to segment.
-Select Output Folder: select a folder to save results.
-all_imagesYN: process all the images (with the same extension .bmp/.jpg...et al ) in the input folder or not.
-save labels: bool flag to indicate whether saving the multi-label segmentation result or not. If yes, the multi-label segmentation result will be saved in a txt file by rows.
-save voronoi PLY: flag to save voronoi partition as PLY format.
-save line-segs PLY: flag to save detected line-segments as PLY format.
-save triangle_polygon: flag to save Delaunay Triangulation, 'vertex' saved in '.vertex' and the relative polygon saved in '.polygon' and '.num' which indicates the number of vertices of each polygon. An example of reading DT and polygons will be given at the end of this document.
-Specific ProMap: user can give a specific probability map (an image) to guide the 'homogeniesation' operation in the paper. If yes, tick and open the prob_image.


//=============================================================================
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_info & DT, 
	int & width,
	int & height)
{
	//// load triangle and vcell 
	DT.clear();
	std::ifstream ifs(filenameNoEx+".vertex");
	std::ifstream ifsN(filenameNoEx+".num");
	std::ifstream ifsV(filenameNoEx+".polygon");
	if(ifs.fail())
	{
		std::cout<<red<<"NO vertex file existed! Cannot load DT."<<white<<std::endl;
		return false;
	}
	Point_2 p, vcp;
	int num(0);
	int count(0);
	Triangulation_D::Vertex_handle vh;
	ifs>>width; ifs>>height;
	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); //each vertex has a polygon (voronoi cell)
				else
					return false;
			}
		}
		else return false;
	}
	return true;
}

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