void WriteData(Agglomerative &A, ModelFile &Model)
{

	std::vector<unsigned int> PointLabels = A.getPointLabels();
	
	std::vector<unsigned int> UniqueLabels = Tools::UniqueElements(PointLabels);
	std::vector<Color<unsigned char> > Colors = Spectrum(UniqueLabels.size());

	for(unsigned int label = 0; label < UniqueLabels.size(); label++)
	{
		for(unsigned int p = 0; p < Model.NumPoints(); p++)
		{
			if(PointLabels[p] == UniqueLabels[label])
				Model.Points_[p].setColor(Colors[label]);
		}
	}
	
	Model.Write("Clusters.vtp");
	
	vsl_b_ofstream outputPDM("PointDistanceMatrix.bin");
	vsl_b_write(outputPDM, A.PointDistanceMatrix);
	outputPDM.close();
	
	vbl_array_2d<double> CDMValue(PointLabels.size(), PointLabels.size());
	vbl_array_2d<bool> CDMValid(PointLabels.size(), PointLabels.size());
	for(unsigned int i = 0; i < PointLabels.size(); i++)
	{
		for(unsigned int j = 0; j < PointLabels.size(); j++)
		{
			CDMValue(i,j) = A.ClusterDistanceMatrix(i,j).Value;
			CDMValid(i,j) = A.ClusterDistanceMatrix(i,j).Valid;
		}
	}
	vsl_b_ofstream outputCDMValue("ClusterDistanceMatrixValue.bin");
	vsl_b_write(outputCDMValue, CDMValue);
	outputCDMValue.close();
	
	vsl_b_ofstream outputCDMValid("ClusterDistanceMatrixValid.bin");
	vsl_b_write(outputCDMValid, CDMValid);
	outputCDMValid.close();
	/*
	vsl_b_ofstream outputCDM("ClusterDistanceMatrix.bin");
	vsl_b_write(outputCDM, A.ClusterDistanceMatrix);
	outputCDM.close();
	*/
	
	vsl_b_ofstream outputPL("PointLabels.bin");
	vsl_b_write(outputPL, PointLabels);
	outputPL.close();
}
示例#2
0
void VglPlus::savePointVector(const char *fileName, const char *imageName, const vcl_vector<vgl_point_2d<double>> &wldPts, const vcl_vector< vgl_point_2d<double> > &imgPts)
{
    assert(wldPts.size() == imgPts.size());
    
    vsl_b_ofstream bfs_out(fileName);
    
    vsl_b_write(bfs_out, imageName);          // image name
    vsl_b_write(bfs_out, (int)wldPts.size()); // pts number
    
    for (int i = 0; i<wldPts.size(); i++) {
        vsl_b_write(bfs_out, wldPts[i]);
    }
    for (int i = 0; i<imgPts.size(); i++) {
        vsl_b_write(bfs_out, imgPts[i]);
    }
    
    bfs_out.close();
}
示例#3
0
void VglPlus::saveMatrix(const char *fileName, const vnl_matrix<double> & data)
{
    vsl_b_ofstream bfs_out(fileName);
    vcl_cout<<"save to "<<fileName<<vcl_endl;
    
    vsl_b_write(bfs_out, data);
    
    bfs_out.close();
}
示例#4
0
void VglPlus::savePointVector(const char *fileName, vcl_vector<vgl_point_2d<double>> &pts)
{
    vsl_b_ofstream bfs_out(fileName);
    vcl_cout<<"save point vector, size is "<<pts.size()<<vcl_endl;
    
    for (int i = 0; i<pts.size(); i++) {
        vsl_b_write(bfs_out, pts[i]);
    }
    bfs_out.close();
}
示例#5
0
bool VilGMM::write(const char *fileName)
{
    assert(gmm_);
    assert(fileName);
    
    vsl_add_to_binary_loader(vpdfl_pc_gaussian());
    vsl_add_to_binary_loader(vpdfl_mixture());
    vsl_add_to_binary_loader(vpdfl_gaussian());
    
    vsl_b_ofstream bfs_out(fileName);
    vsl_b_write(bfs_out, gmm_);
    bfs_out.close();
    printf("write to %s\n", fileName);
    return true;
}