[vtkusers] Images and countours
Robert Milaszewski
rmilas at head.cfa.harvard.edu
Mon Jan 12 12:42:16 EST 2004
Hello,
I created application that reads in an image and overlays contours
on top. The image is around 350x350 pixels and there are 10 levels
in contours. Here are parts of the code to create image:
vtkImageActor* imageActor;
vtkFITSReader* imageReader=vtkFITSReader::New();
vtkImageShiftScale* imageShiftScale=vtkImageShiftScale::New();
imageActor = vtkImageActor::New();
imageReader->SetDataSpacing(0.8,0.8,1.5);
imageReader->SetFileName(inFileName.c_str());
imageShiftScale->SetInput(imageReader->GetOutput());
imageShiftScale->SetShift(0);
imageShiftScale->SetScale(1);
imageShiftScale->SetOutputScalarTypeToUnsignedChar();
imageActor->SetInput(imageShiftScale->GetOutput());
renderer->AddActor(imageActor);
and the contour:
vtkActor* contActor;
vtkFITSReader* imageReader=vtkFITSReader::New();
vtkImageShiftScale* imageShiftScale=vtkImageShiftScale::New();
imageReader->SetFileName(inFileName.c_str());
imageShiftScale->SetInput(imageReader->GetOutput());
imageShiftScale->SetOutputScalarTypeToUnsignedChar();
vtkContourFilter* contFilter = vtkContourFilter::New();
contFilter->SetInput(imageShiftScale->GetOutput());
contFilter->GenerateValues(inLevelCount,inLowVal,inHighVal);
vtkPolyDataMapper* contMapper = vtkPolyDataMapper::New();
contMapper->SetInput(contFilter->GetOutput());
contMapper->SetScalarRange(inLowVal,inHighVal);
contMapper->SetColorMode(5);
contActor=vtkActor::New();
contActor->SetMapper(contMapper);
renderer->AddActor(contActor);
I use vtkRenderWindowInteractor with vtkInteractorStyleImage.
Contour calculations take a very long time for large images
and mouse interactions with image/contour(translation, scaling,
rotation)
can be very slow, I wonder if there is anything that I could do
more efficiently in my code to improve that performance.
For example using vtkActor2D, and vtkPolyDataMapper2D,
or different window interactor.
thanks,
Robert M Milaszewski
More information about the vtkusers
mailing list