[vtkusers] vtkImageMathematics
Matthias Haack
haack at rz.rwth-aachen.de
Sun Aug 31 07:58:17 EDT 2003
Hi,
I tried to use the class vtkImageMathematics to invert the image colors.
At the moment I do not really understand what to do with the two inputs
in this case because an invert operation only need one image (or: What
does the vtkImageMathematics invert operation really do?)
I fed an image to input number one, set the operation to invert and
fetched the resulting image from vtkImageMathematics via GetOutput() but
the image was only black and not inverted. I used vtkImageActor and a
vtkRendererWindow to render it.
Can anyone explain to me what I did wrong? I'm using vtk 4.0.2.
Here's an example (the reader has definitely a valid image as filename,
I also stripped includes and variable definitions):
imData = pngReader->GetOutput();
imData->Update();
imData->Register(0);
pngReader->SetOutput(0);
pngReader->Delete();
imActor = vtkImageActor::New();
imActor->SetInput(imData);
renderer= vtkRenderer::New();
renderer->AddProp(imActor);
renWindow = vtkRenderWindow::New();
renWindow->AddRenderer(renderer);
int i=1;
while(i<10) {
renWindow->Render();
sleep(1);
vtkImageMathematics* math = vtkImageMathematics::New();
math->SetOperationToInvert();
vtkImageData* temp = vtkImageData::New();
math->SetInput1(imData);
temp = math->GetOutput();
temp->Update();
imData->DeepCopy(temp);
math->RemoveAllInputs();
temp->Register(0);
temp->Delete();
math->Delete();
}
As I wrote above, the resulting image is fully black.
thanks in advance
Matthias
More information about the vtkusers
mailing list