コード例 #1
0
void
NeuronsStackView::updateOutputs() {

	util::rect<double> oldSize = _painter->getSize();

	if (_neuronsModified) {

		_painter->setNeurons(_neurons);

		_neuronsModified = false;
	}

	if (_currentNeuronModified) {

		_painter->showNeuron(*_currentNeuron);

		_currentNeuronModified = false;
	}

	util::rect<double> newSize = _painter->getSize();

	if (oldSize == newSize) {

		LOG_ALL(neuronsstackviewlog) << "neurons size did not change -- sending ContentChanged" << std::endl;

		_contentChanged();

	} else {

		LOG_ALL(neuronsstackviewlog) << "neurons size did change -- sending SizeChanged" << std::endl;

		_sizeChanged();
	}
}
コード例 #2
0
void
SegmentsStackView::updateOutputs() {

	util::rect<double> oldSize = _painter->getSize();

	// set new or modified segments
	if (_segmentsModified) {

		_painter->setSegments(_segments);

		_segmentsModified = false;
	}

	// query visible segments
	_painter->getVisibleSegments(*_visibleSegments);

	LOG_ALL(segmentsstackviewlog) << "there are " << _visibleSegments->size() << " visible segments" << std::endl;

	// get new size of painter
	util::rect<double> newSize = _painter->getSize();

	if (oldSize == newSize) {

		LOG_ALL(segmentsstackviewlog) << "segments size did not change -- sending ContentChanged" << std::endl;

		_contentChanged();

	} else {

		LOG_ALL(segmentsstackviewlog) << "segments size did change -- sending SizeChanged" << std::endl;

		_sizeChanged();
	}
}
コード例 #3
0
ファイル: Reconstructor.cpp プロジェクト: thanujadax/sopnet
void
Reconstructor::updateReconstruction() {

	// remove all previous segment in the reconstruction
	_reconstruction->clear();
	_discardedSegments->clear();

	LOG_ALL(reconstructorlog) << "Solution consists of segments: ";

	_currentSegmentNum = 0;

	foreach (boost::shared_ptr<EndSegment> segment, _segments->getEnds())
		probe(segment);

	foreach (boost::shared_ptr<ContinuationSegment> segment, _segments->getContinuations())
		probe(segment);

	foreach (boost::shared_ptr<BranchSegment> segment, _segments->getBranches())
		probe(segment);

	foreach (boost::shared_ptr<SegmentPair> segment, _segments->getSegmentPairs())
			probe(segment);

	foreach (boost::shared_ptr<SegmentPairEnd> segment, _segments->getSegmentPairEnds())
			probe(segment);

	LOG_ALL(reconstructorlog) << std::endl;

}
コード例 #4
0
void
ImageStackView::updateOutputs() {

	util::rect<double> oldSize = _painter->getSize();

	_painter->setImageStack(_stack);
	_painter->setCurrentSection(_section);

	util::rect<double> newSize = _painter->getSize();

	if (oldSize == newSize) {

		LOG_ALL(imagestackviewlog) << "image size did not change -- sending ContentChanged" << std::endl;

		_contentChanged();

	} else {

		LOG_ALL(imagestackviewlog) << "image size did change -- sending SizeChanged" << std::endl;

		_sizeChanged();
	}

	if (_stack->size() == 0)
		return;

	// prepare current image data
	_currentImageData.reshape(vigra::MultiArray<2, float>::size_type(_stack->width(), _stack->height()));

	// copy current image data
	_currentImageData = *(*_stack)[_section];

	// set content of output
	*_currentImage = _currentImageData;
}
コード例 #5
0
void
ImageStackView::onKeyDown(gui::KeyDown& signal) {

	LOG_ALL(imagestackviewlog) << "got a key down event" << std::endl;

	if (signal.key == gui::keys::A) {

		_section = std::max(0, _section - 1);

		LOG_ALL(imagestackviewlog) << "setting current section to " << _section << std::endl;

		setDirty(_painter);
		setDirty(_currentImage);
	}

	if (signal.key == gui::keys::D) {

		_section = std::min((int)_stack->size() - 1, _section + 1);

		LOG_ALL(imagestackviewlog) << "setting current section to " << _section << std::endl;

		setDirty(_painter);
		setDirty(_currentImage);
	}
}
コード例 #6
0
void
SegmentFeaturesExtractor::FeaturesAssembler::updateOutputs() {

	LOG_DEBUG(segmentfeaturesextractorlog) << "assembling features from " << _features.size() << " feature groups" << std::endl;

	_allFeatures->clear();

	foreach (boost::shared_ptr<Features> features, _features) {

		LOG_ALL(segmentfeaturesextractorlog) << "processing feature group" << std::endl << std::endl << *features << std::endl;

		foreach (const std::string& name, features->getNames()) {

			LOG_ALL(segmentfeaturesextractorlog) << "adding name " << name << std::endl;
			_allFeatures->addName(name);
		}

		if (_allFeatures->size() == 0) {

			LOG_ALL(segmentfeaturesextractorlog) << "initialising all features with " << features->size() << " feature vectors from current feature group" << std::endl;

			unsigned int numFeatures = (features->size() > 0  ? (*features)[0].size() : 0);

			_allFeatures->resize(features->size(), numFeatures);

			unsigned int i = 0;
			foreach (const std::vector<double>& feature, *features) {

				std::copy(feature.begin(), feature.end(), (*_allFeatures)[i].begin());
				i++;
			}

		} else {
コード例 #7
0
TolerantEditDistance::TolerantEditDistance() :
	_haveBackgroundLabel(optionHaveBackgroundLabel),
	_gtBackgroundLabel(optionGroundTruthBackgroundLabel),
	_recBackgroundLabel(optionReconstructionBackgroundLabel),
	_correctedReconstruction(new ImageStack()),
	_splitLocations(new ImageStack()),
	_mergeLocations(new ImageStack()),
	_fpLocations(new ImageStack()),
	_fnLocations(new ImageStack()),
	_errors(_haveBackgroundLabel ? new Errors(_gtBackgroundLabel, _recBackgroundLabel) : new Errors()) {

	if (optionHaveBackgroundLabel) {
		LOG_ALL(tedlog) << "started TolerantEditDistance with background label" << std::endl;
	} else {
		LOG_ALL(tedlog) << "started TolerantEditDistance without background label" << std::endl;
	}

	registerInput(_groundTruth, "ground truth");
	registerInput(_reconstruction, "reconstruction");

	registerOutput(_correctedReconstruction, "corrected reconstruction");
	registerOutput(_splitLocations, "splits");
	registerOutput(_mergeLocations, "merges");
	registerOutput(_fpLocations, "false positives");
	registerOutput(_fnLocations, "false negatives");
	registerOutput(_errors, "errors");

	_toleranceFunction = new DistanceToleranceFunction(optionToleranceDistanceThreshold.as<float>(), _haveBackgroundLabel, _recBackgroundLabel);
}
コード例 #8
0
ファイル: SwitchImpl.cpp プロジェクト: funkey/gui
void
SwitchImpl::onMouseMove(MouseMove& signal) {

	LOG_ALL(switchlog) << "mouse moved at " << signal.position << std::endl;

	const util::rect<double>& size = _painter->getSize();

	if (size.contains(signal.position)) {

		LOG_ALL(switchlog) << "...inside switch" << std::endl;

		if (_mouseOver == false) {

			_mouseOver = true;

			_painter->setHighlight(true);

			setDirty(_painter);
		}

	} else {

		LOG_ALL(switchlog) << "...outside switch" << std::endl;

		if (_mouseOver == true) {

			_mouseOver = false;

			_painter->setHighlight(false);

			setDirty(_painter);
		}
	}
}
コード例 #9
0
ファイル: Reconstructor.cpp プロジェクト: akreshuk/sopnet
void
Reconstructor::updateReconstruction() {

	boost::timer::auto_cpu_timer timer("\tReconstructor::updateReconstruction():\t%ws\n");

	// remove all previous segment in the reconstruction
	_reconstruction->clear();
	_reconstruction->setResolution(
			_segments->getResolutionX(),
			_segments->getResolutionY(),
			_segments->getResolutionZ());
	_discardedSegments->clear();
	_discardedSegments->setResolution(
			_segments->getResolutionX(),
			_segments->getResolutionY(),
			_segments->getResolutionZ());

	LOG_ALL(reconstructorlog) << "Solution consists of segments: ";

	_currentSegmentNum = 0;

	foreach (boost::shared_ptr<EndSegment> segment, _segments->getEnds())
		probe(segment);

	foreach (boost::shared_ptr<ContinuationSegment> segment, _segments->getContinuations())
		probe(segment);

	foreach (boost::shared_ptr<BranchSegment> segment, _segments->getBranches())
		probe(segment);

	LOG_ALL(reconstructorlog) << std::endl;
}
コード例 #10
0
void
SegmentExtractor::extractSegments() {

	LOG_DEBUG(segmentextractorlog)
			<< "previous sections contains " << _prevSlices->size() << " slices,"
			<< "next sections contains "     << _nextSlices->size() << " slices" << std::endl;

	LOG_ALL(segmentextractorlog) << "Branch overlap threshold: " << _branchOverlapThreshold << std::endl;
	LOG_ALL(segmentextractorlog) << "Branch size ratio threshold: " << _branchSizeRatioThreshold << std::endl;

			
	buildOverlapMap();

	unsigned int oldSize = 0;

	LOG_DEBUG(segmentextractorlog) << "extracting segments..." << std::endl;

	LOG_DEBUG(segmentextractorlog) << "extracting continuations to next section..." << std::endl;

	// for all slices in previous section...
	for (unsigned int i = 0; i < _prevSlices->size(); i++) {

		LOG_ALL(segmentextractorlog) << "found " << _nextOverlaps[i].size() << " partners" << std::endl;

		// ...and all overlapping slices in the next section...
		unsigned int j, overlap;
		foreach (boost::tie(overlap, j), _nextOverlaps[i]) {

			// ...try to extract the segment
			extractSegment((*_prevSlices)[i], (*_nextSlices)[j], overlap);
		}
	}
コード例 #11
0
void
ImageStackPainter::setCurrentSection(unsigned int section) {

	if (_showColored)
		return;

	if (!_stack || _stack->size() == 0 || _imagePainters.size() == 0)
		return;

	_section = std::min(section, _stack->size() - 1);

	for (unsigned int i = 0; i < _numImages; i++) {

		int imageIndex = std::max(std::min(static_cast<int>(_section) + static_cast<int>(i - _numImages/2), static_cast<int>(_stack->size()) - 1), 0);

		LOG_ALL(imagestackpainterlog) << "index for image " << i << " is " << imageIndex << std::endl;

		_imagePainters[i]->setImage((*_stack)[imageIndex]);

		if ((*_stack)[imageIndex]->getIdentifier() != "")
			LOG_USER(imagestackpainterlog) << "showing image " << (*_stack)[imageIndex]->getIdentifier() << std::endl;
	}

	util::rect<double> size = _imagePainters[0]->getSize();

	_imageHeight = size.height();

	size.minY -= _numImages/2*_imageHeight + _numImages*_gap/2;
	size.maxY += (_numImages/2 - (_numImages + 1)%2)*_imageHeight + _numImages*_gap/2;

	setSize(size);

	LOG_ALL(imagestackpainterlog) << "current section set to " << _section << std::endl;
}
コード例 #12
0
ファイル: ContainerPainter.cpp プロジェクト: funkey/gui
void
ContainerPainter::remove(boost::shared_ptr<Painter> painter) {

	LOG_ALL(containerpainterlog) << "removing painter " << typeName(*painter) << std::endl;

	{
		// get a write lock
		boost::unique_lock<boost::shared_mutex> lock(_paintersMutex);

		// remove painter from list
		for (std::vector<content_type>::iterator i = _content.begin(); i != _content.end(); i++) {

			if ((*i).first == painter) {

				_content.erase(i);

				LOG_ALL(containerpainterlog) << "removed." << std::endl;

				break;
			}
		}
	}

	// update size of this painter
	updateSize();
}
コード例 #13
0
ファイル: OpenGl.cpp プロジェクト: ongbe/gui-1
OpenGl::Guard::Guard(GlContextCreator* contextCreator) :
	_openGl(getInstance()) {

	LOG_ALL(opengllog) << "[Guard] creating new factory guard" << std::endl;

	if (contextCreator == 0) {

		LOG_ALL(opengllog) << "[Guard] destructing current thread's context" << std::endl;

		invalidateCurrentContext();

		_deactivateContext = false;

		return;
	}

	LOG_ALL(opengllog) << "[Guard] ensuring valid context" << std::endl;

	// remember to deactivate the context on destruction
	_deactivateContext = true;

	if (getPreviousContextCreator() == contextCreator && reusePreviousContext()) {

		LOG_ALL(opengllog) << "[Guard] could reuse previous context from the same creator" << std::endl;

		return;

	} else {

		LOG_ALL(opengllog) << "[Guard] previous context not present or invalid -- create a new one" << std::endl;

		createNewContex(contextCreator);
	}
}
コード例 #14
0
void
TolerantEditDistance::extractCells() {

	if (_groundTruth->size() != _reconstruction->size())
		BOOST_THROW_EXCEPTION(SizeMismatchError() << error_message("ground truth and reconstruction have different size") << STACK_TRACE);

	if (_groundTruth->height() != _reconstruction->height() || _groundTruth->width() != _reconstruction->width())
		BOOST_THROW_EXCEPTION(SizeMismatchError() << error_message("ground truth and reconstruction have different size") << STACK_TRACE);

	_depth  = _groundTruth->size();
	_width  = _groundTruth->width();
	_height = _groundTruth->height();

	LOG_ALL(tedlog) << "extracting cells in " << _width << "x" << _height << "x" << _depth << " volume" << std::endl;

	vigra::MultiArray<3, std::pair<float, float> > gtAndRec(vigra::Shape3(_width, _height, _depth));
	vigra::MultiArray<3, unsigned int>             cellIds(vigra::Shape3(_width, _height, _depth));

	// prepare gt and rec image

	for (unsigned int z = 0; z < _depth; z++) {

		boost::shared_ptr<Image> gt  = (*_groundTruth)[z];
		boost::shared_ptr<Image> rec = (*_reconstruction)[z];

		for (unsigned int x = 0; x < _width; x++)
			for (unsigned int y = 0; y < _height; y++) {

				float gtLabel  = (*gt)(x, y);
				float recLabel = (*rec)(x, y);

				gtAndRec(x, y, z) = std::make_pair(gtLabel, recLabel);
			}
	}

	// find connected components in gt and rec image
	cellIds = 0;
	_numCells = vigra::labelMultiArray(gtAndRec, cellIds);

	LOG_DEBUG(tedlog) << "found " << _numCells << " cells" << std::endl;

	// let tolerance function extract cells from that
	_toleranceFunction->extractCells(
			_numCells,
			cellIds,
			*_reconstruction,
			*_groundTruth);

	LOG_ALL(tedlog)
			<< "found "
			<< _toleranceFunction->getGroundTruthLabels().size()
			<< " ground truth labels and "
			<< _toleranceFunction->getReconstructionLabels().size()
			<< " reconstruction labels"
			<< std::endl;
}
コード例 #15
0
void
SubStackSelector::updateOutputs() {

	if (!_subStack)
		_subStack = new ImageStack();

	LOG_ALL(substackselectorlog)
			<< "selecting substack from stack of size "
			<< _stack->size() << std::endl;

	LOG_ALL(substackselectorlog)
			<< "first section is " << _firstImage
			<< ", last section is " << _lastImage
			<< std::endl;

	if (_firstImage < 0) {

		LOG_ALL(substackselectorlog)
				<< "first section is negative, will set it to 0"
				<< std::endl;

		_firstImage = 0;
	}

	unsigned int lastImage = (_lastImage <= 0 ? _stack->size() - 1 + _lastImage : _lastImage);

	LOG_ALL(substackselectorlog)
			<< "set last section to " << lastImage
			<< std::endl;

	if (lastImage > _stack->size() - 1) {

		LOG_ERROR(substackselectorlog)
				<< "parameter last section (" << lastImage << ") "
				<< "is bigger than number of images in given stack -- "
				<< "will use " << (_stack->size() - 1) << " instead"
				<< std::endl;

		lastImage = _stack->size() - 1;
	}

	_subStack->clear();
	for (unsigned int i = _firstImage; i <= lastImage; i++)
		_subStack->add((*_stack)[i]);

	// set the resolution of the substack
	float resX = _stack->getResolutionX();
	float resY = _stack->getResolutionY();
	float resZ = _stack->getResolutionZ();

	_subStack->setResolution(resX, resY, resZ);
	_subStack->setOffset(
			_stack->getBoundingBox().min().x(),
			_stack->getBoundingBox().min().y(),
			_stack->getBoundingBox().min().z() + _firstImage*resZ);
}
コード例 #16
0
ファイル: OpenGl.cpp プロジェクト: ongbe/gui-1
OpenGl::~OpenGl() {

	LOG_ALL(opengllog) << "destructing..." << std::endl;

	_globalContext->activate(false);
	if (_globalContext)
		delete _globalContext;

	LOG_ALL(opengllog) << "destructed" << std::endl;
}
コード例 #17
0
ファイル: OpenGl.cpp プロジェクト: ongbe/gui-1
OpenGl::Guard::~Guard() {

	LOG_ALL(opengllog) << "[Guard] destructing" << std::endl;

	if (_deactivateContext) {

		LOG_ALL(opengllog) << "[Guard] deactivating context" << std::endl;

		// deactivate the context for this thread
		_openGl->_context->activate(false);
	}
}
コード例 #18
0
ファイル: SegmentsPainter.cpp プロジェクト: ottj/sopnet
void
SegmentsPainter::drawSlice(
		boost::shared_ptr<Slice> slice,
		double red, double green, double blue) {

	double section = slice->getSection();

	LOG_ALL(segmentspainterlog)
			<< "drawing slice " << slice->getId()
			<< " in section " << section << std::endl;

	double z = _zScale*section;

	glCheck(glColor4f(red, green, blue, 1.0));

	_textures.get(slice->getId())->bind();

	glBegin(GL_QUADS);

	const util::rect<double>& bb = slice->getComponent()->getBoundingBox();

	if (_leftSide) {

		glTexCoord2d(1.0, 0.0); glNormal3d(0, 0, -1); glVertex3d(bb.maxX, bb.minY, z);
		glTexCoord2d(1.0, 1.0); glNormal3d(0, 0, -1); glVertex3d(bb.maxX, bb.maxY, z);
		glTexCoord2d(0.0, 1.0); glNormal3d(0, 0, -1); glVertex3d(bb.minX, bb.maxY, z);
		glTexCoord2d(0.0, 0.0); glNormal3d(0, 0, -1); glVertex3d(bb.minX, bb.minY, z);
	}

	if (_rightSide) {

		glTexCoord2d(0.0, 0.0); glNormal3d(0, 0, 1); glVertex3d(bb.minX, bb.minY, z);
		glTexCoord2d(0.0, 1.0); glNormal3d(0, 0, 1); glVertex3d(bb.minX, bb.maxY, z);
		glTexCoord2d(1.0, 1.0); glNormal3d(0, 0, 1); glVertex3d(bb.maxX, bb.maxY, z);
		glTexCoord2d(1.0, 0.0); glNormal3d(0, 0, 1); glVertex3d(bb.maxX, bb.minY, z);
	}

	glCheck(glEnd());

	LOG_ALL(segmentspainterlog) << "done." << std::endl;

	if (_size == util::rect<double>(0, 0, 0, 0))

		_size = bb;

	else {

		_size.minX = std::min(_size.minX, bb.minX);
		_size.minY = std::min(_size.minY, bb.minY);
		_size.maxX = std::max(_size.maxX, bb.maxX);
		_size.maxY = std::max(_size.maxY, bb.maxY);
	}
}
コード例 #19
0
ファイル: OpenGl.cpp プロジェクト: ongbe/gui-1
void
OpenGl::flush() {

	LOG_ALL(opengllog) << "attempting to flush current context" << std::endl;

	GlContext* context = getInstance()->_context.get();

	if (context != 0)
		context->flush();
	else
		LOG_ALL(opengllog) << "there is no current context in this thread" << std::endl;
}
コード例 #20
0
std::set<Crag::CragNode>
AdjacencyAnnotator::recurseAdjacencies(Crag& crag, Crag::CragNode n) {

	LOG_ALL(adjacencyannotatorlog) << "recursing into node " << crag.id(n) << std::endl;

	// get all leaf subnodes
	std::set<Crag::CragNode> subnodes;
	for (Crag::CragArc a : crag.inArcs(n)) {

		std::set<Crag::CragNode> a_subnodes = recurseAdjacencies(crag, a.source());

		for (Crag::CragNode s : a_subnodes)
			subnodes.insert(s);
	}

	// for each leaf subnode adjacent to a non-subnode, add an adjacency edge to 
	// the non-subnode
	std::set<Crag::CragNode> neighbors;

	LOG_ALL(adjacencyannotatorlog) << "subnodes of " << crag.id(n) << " are:" << std::endl;
	for (Crag::CragNode s : subnodes) {

		LOG_ALL(adjacencyannotatorlog) << "\t" << crag.id(s) << std::endl;

		for (Crag::CragEdge e : crag.adjEdges(s)) {

			Crag::CragNode neighbor = e.opposite(s);

			// not a subnode
			if (!subnodes.count(neighbor))
				neighbors.insert(neighbor);
		}
	}

	for (Crag::CragNode neighbor : neighbors) {

		LOG_ALL(adjacencyannotatorlog)
				<< "adding propagated edge between "
				<< crag.id(n) << " and " << crag.id(neighbor)
				<< std::endl;

		crag.addAdjacencyEdge(n, neighbor);
	}

	_numAdded += neighbors.size();

	subnodes.insert(n);

	LOG_ALL(adjacencyannotatorlog) << "leaving node " << crag.id(n) << std::endl;

	return subnodes;
}
コード例 #21
0
void
GroundTruthExtractor::SegmentsAssembler::updateOutputs() {

	LOG_ALL(groundtruthextractorlog)
			<< "assembling segments from "
			<< _segments.size() << " inter-section intervals"
			<< std::endl;

	_allSegments->clear();

	foreach (boost::shared_ptr<Segments> segments, _segments) {

		LOG_ALL(groundtruthextractorlog) << "adding " << segments->size() << " segments" << std::endl;

		_allSegments->addAll(segments);
	}
コード例 #22
0
bool
ImageStackPainter::draw(
		const util::rect<double>&  roi,
		const util::point<double>& resolution) {

	LOG_ALL(imagestackpainterlog) << "redrawing section " << _section << std::endl;

	if (_showColored) {

		for (int i = 0; i < _stack->size(); i++) {

			_imagePainters[i]->draw(roi, resolution);
		}

	} else {

		for (int i = 0; i < _numImages; i++) {

			int offset = i - _numImages/2;

			glTranslated(0, -offset*_imageHeight, 0);

			_imagePainters[i]->draw(roi - util::point<double>(static_cast<double>(0), -offset*_imageHeight), resolution);

			glTranslated(0,  offset*_imageHeight, 0);
		}
	}

	return false;
}
コード例 #23
0
void
ImageStackPainter::setImageStack(boost::shared_ptr<ImageStack> stack) {

	LOG_ALL(imagestackpainterlog) << "got a new stack" << std::endl;

	_stack = stack;

	if (_stack && _section >= _stack->size())
		setCurrentSection(0);

	if (_showColored) {

		_imagePainters.clear();

		for (unsigned int i = 0; i < _stack->size(); i++) {

			boost::shared_ptr<gui::ImagePainter<Image> > painter = boost::make_shared<gui::ImagePainter<Image> >();
			painter->setImage((*_stack)[i]);
			painter->setColor(
				(i < _reds.size()   ? _reds[i]   : static_cast<float>(rand())/RAND_MAX),
				(i < _greens.size() ? _greens[i] : static_cast<float>(rand())/RAND_MAX),
				(i < _blues.size()  ? _blues[i]  : static_cast<float>(rand())/RAND_MAX));
			painter->setTransparent(true);

			_imagePainters.push_back(painter);

			setSize(painter->getSize());
		}
	}
}
コード例 #24
0
void
ImageStackView::onButtonDown(gui::MouseDown& signal) {

	LOG_ALL(imagestackviewlog) << "got a mouse down event" << std::endl;

	if (signal.button == gui::buttons::Left && signal.modifiers == 0) {

		_mouseDownX = signal.position.x;
		_mouseDownY = signal.position.y;

		LOG_ALL(imagestackviewlog) << "setting click position to (" << _mouseDownX << ", " << _mouseDownY << ")" << std::endl;

		setDirty(_clickX);
		setDirty(_clickY);
	}
}
コード例 #25
0
ファイル: MserDialog.cpp プロジェクト: ottj/sopnet
MserDialog::MserDialog() :
	_deltaSlider(boost::make_shared<gui::Slider>("delta", 0, 256, 1)),
	_minAreaSlider(boost::make_shared<gui::Slider>("min area", 0, 100000)),
	_maxAreaSlider(boost::make_shared<gui::Slider>("max area", 0, 100000, 10000)),
	_maxVariationSlider(boost::make_shared<gui::Slider>("max variation", 0.0, 10.0, 10.0)),
	_minDiversitySlider(boost::make_shared<gui::Slider>("min diversity", 0.0, 10.0, 0.2)),
	_gui(boost::make_shared<gui::ContainerView<gui::VerticalPlacing> >()),
	_parametersCollector(boost::make_shared<ParametersCollector>()) {

	LOG_ALL(mserdialoglog) << "create new mser dialog" << std::endl;

	// establish internal pipeline connections
	_parametersCollector->setInput("delta",         _deltaSlider->getOutput("value"));
	_parametersCollector->setInput("min area",      _minAreaSlider->getOutput("value"));
	_parametersCollector->setInput("max area",      _maxAreaSlider->getOutput("value"));
	_parametersCollector->setInput("max variation", _maxVariationSlider->getOutput("value"));
	_parametersCollector->setInput("min diversity", _minDiversitySlider->getOutput("value"));

	_gui->setAlign(gui::VerticalPlacing::Left);
	_gui->addInput(_deltaSlider->getOutput("painter"));
	_gui->addInput(_minAreaSlider->getOutput("painter"));
	_gui->addInput(_maxAreaSlider->getOutput("painter"));
	_gui->addInput(_maxVariationSlider->getOutput("painter"));
	_gui->addInput(_minDiversitySlider->getOutput("painter"));

	registerOutput(_parametersCollector->getOutput(), "mser parameters");
	registerOutput(_gui->getOutput(), "painter");
}
コード例 #26
0
ファイル: OpenGl.cpp プロジェクト: ongbe/gui-1
OpenGl::OpenGl() :
	_globalContext(0) {

	LOG_DEBUG(opengllog) << "creating global glxContext" << std::endl;

	// use default context settings
	ContextSettings defaultSettings;

	// create offline context (has a dummy window)
	_globalContext = new GlContext(defaultSettings);

	// set active for this thread
	if (!_globalContext->activate())
		LOG_ERROR(opengllog) << "failed to activate global context" << std::endl;

	// initialize GLEW for extension checks
	if (glewInit() != GLEW_OK)
		LOG_ERROR(opengllog) << "GLEW did not initialize" << std::endl;

	// see if pixel buffer objects are supported
	if (!glewIsSupported("GL_ARB_pixel_buffer_object"))
		LOG_ERROR(opengllog) << "pixel buffer extension not supported" << std::endl;

	LOG_ALL(opengllog) << "Initialized" << std::endl;
}
コード例 #27
0
ファイル: ContainerPainter.cpp プロジェクト: funkey/gui
bool
ContainerPainter::draw(
			const util::rect<double>&  roi,
			const util::point<double>& resolution) {

	LOG_ALL(containerpainterlog) << "redrawing..." << std::endl;

	// get a read-lock
	boost::shared_lock<boost::shared_mutex> lock(_paintersMutex);

	LOG_ALL(containerpainterlog) << "got a read-lock" << std::endl;

	bool wantsRedraw = false;

	// draw each painter at its offset position in reverse order, such that the 
	// painter who gets the signals first is drawn last (i.e., on top of the 
	// others)
	for (std::vector<content_type>::reverse_iterator i = _content.rbegin();
	     i != _content.rend(); i++) {

		const boost::shared_ptr<Painter>& painter = i->first;
		const util::point<double>&        offset  = i->second;
		const util::rect<double>&         painterSize = painter->getSize();

		LOG_ALL(containerpainterlog) << "drawing painter " << typeName(*painter) << " at " << offset << std::endl;

		// draw the painter only if it is visible
		if ((painterSize + offset).intersects(roi)) {

			glTranslated(offset.x, offset.y, 0);

			bool painterWantsRedraw = painter->draw(roi - offset, resolution);
			wantsRedraw = wantsRedraw || painterWantsRedraw;

			glTranslated(-offset.x, -offset.y, 0);

		} else {

			LOG_ALL(containerpainterlog) << "nope, this one is currently not visible" << std::endl;
		}
	}

	LOG_ALL(containerpainterlog) << "done redrawing" << std::endl;

	return wantsRedraw;
}
コード例 #28
0
ファイル: TextView.cpp プロジェクト: ongbe/gui-1
void
TextView::onUpdate(const pipeline::Update& signal) {

	LOG_ALL(textviewlog) << "got an update signal" << std::endl;

	if (_dirty) {

		LOG_ALL(textviewlog) << "I'm dirty, resetting my text" << std::endl;

		_painter->setText(_text);
		_dirty = false;

		LOG_ALL(textviewlog) << "sending size changed signal" << std::endl;

		_sizeChanged();
	}
}
コード例 #29
0
void
SliceExtractor<Precision>::onInputSet(const pipeline::InputSetBase&) {

	LOG_ALL(sliceextractorlog) << "using non-default mser parameters" << std::endl;

	// don't use the default
	_mser->setInput("parameters", _mserParameters);
}
コード例 #30
0
void
DistanceToleranceFunction::enumerateCellLabels(const ImageStack& recLabels) {

	_maxDistanceThresholdX = std::min((float)_width,  _maxDistanceThreshold/_resolutionX);
	_maxDistanceThresholdY = std::min((float)_height, _maxDistanceThreshold/_resolutionY);
	_maxDistanceThresholdZ = std::min((float)_depth,  _maxDistanceThreshold/_resolutionZ);

	LOG_DEBUG(distancetolerancelog) << "there are " << _relabelCandidates.size() << " cells that can be relabeled" << std::endl;

	if (_relabelCandidates.size() == 0)
		return;

	LOG_DEBUG(distancetolerancelog) << "creating distance threshold neighborhood" << std::endl;

	// list of all location offsets within threshold distance
	std::vector<cell_t::Location> neighborhood = createNeighborhood();

	LOG_DEBUG(distancetolerancelog) << "there are " << neighborhood.size() << " pixels in the neighborhood for a threshold of " << _maxDistanceThreshold << std::endl;

	// for each cell
	foreach (unsigned int index, _relabelCandidates) {

		cell_t& cell = (*_cells)[index];

		LOG_ALL(distancetolerancelog) << "processing cell " << index << " (label " << cell.getReconstructionLabel() << ")" << std::flush;

		std::set<float> alternativeLabels = getAlternativeLabels(cell, neighborhood, recLabels);

		// every cell that is small enough to be relabelled is allowed to change
		// to background label
		if (_haveBackgroundLabel)
			alternativeLabels.insert(_backgroundLabel);

		LOG_ALL(distancetolerancelog) << "; can map to ";

		// for each alternative label
		foreach (float recLabel, alternativeLabels) {

			LOG_ALL(distancetolerancelog) << recLabel << " ";

			// register possible match
			cell.addAlternativeLabel(recLabel);
			registerPossibleMatch(cell.getGroundTruthLabel(), recLabel);
		}