[vtkusers] Minimal Histogram Visualisation Example needed

Maxima Mustermann Maxima.M at gmx.de
Mon Aug 17 16:15:05 EDT 2009


Hey guys,

I'm trying to compute the Histogram of a Grayscale Image, but it doesn't seem to work.
No compile errors, but no histogram either. (Seems like my code does nothing)

Here's my code:

void showHistogram(const Image2DType* const image)
{
	//convert ITK to VTK
	Converter2DType::Pointer converter = Converter2DType::New();
	converter->SetInput(image);

	converter->Update();

	vtkImageAccumulate* histogram = vtkImageAccumulate::New();
	histogram->SetInput(converter->GetOutput());

	histogram->Update();	//needed?

	vtkXYPlotActor* xyPlot = vtkXYPlotActor::New();
	xyPlot->AddDataObjectInput(histogram->GetOutput());
	
	vtkRenderer* renderer = vtkRenderer::New();
	renderer->SetBackground(0,0,0);
	renderer->AddActor2D(xyPlot);

	vtkRenderWindow* renderWindow = vtkRenderWindow::New();
	renderWindow->SetSize(600, 500);
	renderWindow->AddRenderer(renderer);

	vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
	iren->SetRenderWindow(renderWindow);

	//renderer->Render();	<- my Computer freezes when called
	//iren->Start();	<- does not make difference if I call that - nothing happens
}

I tried to do the same with vtkImageViewer2 (would be the better solution, because easier and more convenient), but same problem there.

Thank you very much in advance, you ITK/VTK guys are awesome!

MM
-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser



More information about the vtkusers mailing list