[Paraview] Saving Programmable Filter as a PNG image
Magician
f_magician at mac.com
Tue Feb 4 11:08:50 EST 2014
Hi all,
I want to save vtkImageData as a PNG image.
The vtkImageData is generated by Programmable Filter.
My PV version is 4.1.0.
I have a small CSV data as below:
> 1,0.5,0
> 0.5,1,0.5
> 0,0.5,1
I opened the data and applied the Programmable Filter as below:
> #Output Data Set Type: vtkImageData
> #Script:
> inp = self.GetInput()
> out = self.GetOutput()
> out.SetDimensions(4, 4, 1)
> out.SetOrigin(0, 0, 0)
> out.SetSpacing(1, 1, 1)
>
> ca = vtk.vtkUnsignedCharArray()
> ca.SetName('image')
> ca.SetNumberOfComponents(3)
> ca.SetNumberOfTuples(9)
>
> out.GetCellData().SetScalars(ca)
> for i in range(3):
> for j in range(3):
> ca.SetTuple3(i * 3 + j, inp.GetValue(i, j).ToFloat() * 255.0, 0.0, 0.0)
>
> #RequestInformation Script:
> from paraview import util
>
> inp = self.GetInput()
> util.SetOutputWholeExtent(self, [0, 3, 0, 3, 0, 0])
I got a 3x3 matrix image on the View.
Then I saved the data as a PNG image, I got the warning and no image was found:
> Warning: In /Users/kitware/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release/paraview/src/paraview/VTK/IO/Image/vtkPNGWriter.cxx, line 198
> vtkPNGWriter (0x11c80a540): PNGWriter only supports unsigned char and unsigned short inputs
How can I save the Programmable Filter as an image?
Magician
More information about the ParaView
mailing list