Ejemplo n.º 1
0
void GrabCut::fitGMMs()
{
	// Step 3: Build GMMs using Orchard-Bouman clustering algorithm
	buildGMMs(*m_backgroundGMM, *m_foregroundGMM, *m_GMMcomponent, *m_image, *m_hardSegmentation);

	// Initialize the graph for graphcut (do this here so that the T-Link debugging image will be initialized)
	initGraph();

	// Build debugging images
	buildImages();
}
Ejemplo n.º 2
0
void GrabCut::setTrimap(int x1, int y1, int x2, int y2, const TrimapValue& t)
{
	(*m_trimap).fillRectangle(x1, y1, x2, y2, t);

	// Immediately set the segmentation as well so that the display will update.
	if (t == TrimapForeground)
		(*m_hardSegmentation).fillRectangle(x1, y1, x2, y2, SegmentationForeground);
	else if (t == TrimapBackground)
		(*m_hardSegmentation).fillRectangle(x1, y1, x2, y2, SegmentationBackground);

	// Build debugging images
	buildImages();
}
Ejemplo n.º 3
0
void DotXsiLoader::process(ExporterBackend& backend, OutSerializer& serializer, bool oneObject)
{
	m_serializer = &serializer;
	ZENIC_ASSERT(m_serializer);

	buildImages(backend);
	buildMaterials(backend);	

	SceneInfo* sceneInfo = zenic_new SceneInfo;
	sceneInfo->setLength(10.0f);	// TODO: Fix this length

	if (!oneObject)
		m_serializer->add(sceneInfo);

	traverseRecursive(m_scene->Root(), backend, *sceneInfo, 0, oneObject);	

	for (std::vector<CSLModel*>::iterator i = m_meshList.begin(); i != m_meshList.end(); ++i)
	{
		CSLModel* model = (*i);
		Node* parentNode = 0;

		if (model->Parent())
			parentNode = backend.findNode(model->Parent());

		Node* node = backend.buildModel(*i); 

		if (parentNode && node && !oneObject)
			parentNode->attachChild(node);

		// If we only want to export one object just add the first we find and exit the loop

		if (oneObject) 
		{
			m_serializer->add(node);
			break;
		}
	}

	// 

	saveMaterialAndImages();
}
Ejemplo n.º 4
0
int GrabCut::refineOnce()
{
	Real flow = 0;

	// Steps 4 and 5: Learn new GMMs from current segmentation
	learnGMMs(*m_backgroundGMM, *m_foregroundGMM, *m_GMMcomponent, *m_image, *m_hardSegmentation);

	// Step 6: Run GraphCut and update segmentation
	initGraph();
	if (m_graph)
		flow = m_graph->maxflow();
	
	int changed = updateHardSegmentation();
	printf("%d pixels changed segmentation (max flow = %f)\n", changed, flow ); 

	// Build debugging images
	buildImages();

	return changed;
}