[vtkusers] Mapping a vtkShepardMethod-generated ImageData to a Texture

Allan James ar.james at qut.edu.au
Thu Mar 18 00:11:07 EDT 2010


Hi Folks,

Could someone please provide some advice with mapping a VTK-generated image data (using vtkShepardMethod) to a polygonal actor?

I can generate a .vti file (vtkXMLImageData) and view it in ParaView and all looks correct - but when I try to write a JPEG or map the image data to a texture, I get nothing - just white.

I have tried different combinations of casting and adding lookup table to vtkTexture without success.

Is it perhaps because the output from vtkShepardMethod is a 3D texture? All I want is a 2D image interpolated from scattered pointset (with all points at z=0)

The test code I am using is as follows:

   _shepard->SetInput(flattenFilter->GetOutput()); // vtkShepardMethod
   _shepard->SetSampleDimensions(500, 500, 1); // outputs a 3D image? - SetSampleDimensions(500, 500, 0) does not work
   _shepard->SetModelBounds(263438.741093, 392234.568386, 6889434.400505, 7052138.258763, -0.1, 0.1);
   _shepard->SetMaximumDistance(1.0);
   _shepard->Update();

    // Cast scalars - double to unsigned char
   vtkSmartPointer<vtkImageCast> castFilter = vtkSmartPointer<vtkImageCast>::New();
   castFilter->SetInput(_shepard->GetOutput());
   castFilter->SetOutputScalarTypeToUnsignedChar();
   castFilter->Update();

   vtkSmartPointer<vtkLookupTable> table = vtkSmartPointer<vtkLookupTable>::New();
   table->SetTableRange(0,255);
   table->SetValueRange(0.0,1.0);
   table->SetSaturationRange(0.0,0.0);
   table->SetHueRange(0.0,0.0);
   table->SetAlphaRange(1.0,1.0);
   table->SetNumberOfColors(256);
   table->Build();

   vtkSmartPointer<vtkImageMapToColors> colorize = vtkSmartPointer<vtkImageMapToColors>::New();
   colorize->SetOutputFormatToRGB();
   colorize->SetLookupTable(table);
   colorize->SetInput(castFilter->GetOutput());
   colorize->Update();

   // At this point have tried adding colorize->GetOutput() to a vtkTexture and mapping to a polydata actor (having correct texture coordinates) without success

   //write JPEG image - output image is all white
   vtkSmartPointer<vtkJPEGWriter> writer = vtkSmartPointer<vtkJPEGWriter>::New();
   writer->SetFileName(buff.str().c_str());
   writer->SetInput(colorize->GetOutput());
   writer->Write();

   // write VTI file - This file displays correctly in ParaView (image shows as an unsigned char with 3 components)
   vtkSmartPointer<vtkXMLImageDataWriter> writer2 = vtkSmartPointer<vtkXMLImageDataWriter>::New();
   writer2->SetFileName(buff2.str().c_str());
   writer2->SetInput(colorize->GetOutput());
   writer2->Update();

Why is the JPEG white while the VTI file displays correctly?

Thanks a heap for any assistance!

Kind regards,

Allan James
High Performance Computing & Research Support
Queensland University of Technology
(07) 3138 9264
ar.james at qut.edu.au<mailto:ar.james at qut.edu.au>
http://www.qut.edu.au/its/hpc

><(((º>  ._.·´¯`·..  >++(((º>  ._.·´¯`·..  >++(((º>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100318/56b0b199/attachment.htm>


More information about the vtkusers mailing list