[vtkusers] Writing renderwindow to an image

Mathieu Malaterre mmalat at imaging.robarts.ca
Thu Jul 4 11:37:53 EDT 2002


Hi Carlos,
  You can use: vtkImageData::GetScalarComponentAsFloat
See:
http://public.kitware.com/VTK/doc/nightly/html/classvtkImageData.html#a56

As you just have 2 coordinates, use this way (in python):

m,n,o = image.GetOutput().GetDimensions()

for i in range(0, m):
 for j in range(0, n):
  val = image.GetOutput().GetScalarComponentAsFloat(i,j,0,0)
  print(val),
 print('\n'),

I'm not sure it's the best way...
mathieu

Carlos Martínez Burgos wrote:

> Yes, this is the idea. I get an vtkImageData object from
> vtkWindowToImageFilter output. Then I should get the pixel values from it.
>
> The problem is that I have never worked with images in VTK so I have
> problems.
>
> Why this object has three components (x,y,z)? I think that this is because
> an image are slices. Isn't it? If it is true, I supose that I have only
> one slice from the window. Is this slice z=0?
>
> How can I get the pixels (rgb) values from the vtkImageData object? I
> supose that this should be sufficient.
>
> Thanks again.
>
> On Thu, 4 Jul 2002, Mathieu Malaterre wrote:
>
> > Hi Carlos,
> >    Why don't you use : vtkWindowToImageFilter.
> > See:
> > http://public.kitware.com/VTK/doc/nightly/html/classvtkWindowToImageFilter.html
> >
> > mathieu
> >
> > Carlos Martínez Burgos wrote:
> >
> > > Hi all.
> > >
> > > I'm working with Java and I have to make reports with the contents of
> > > VTK's renderwindow. I need to do a copy from the renderwindow to an array
> > > of bytes, to build the image and show it.
> > >
> > > Has somebody any idea of doing this? Could somebody help me?
> > >
> > > Thanks.
> > >
> > > --
> > > ----------------------------------------------------------------------
> > > Carlos Martínez Burgos      |     Instituto Tecnológico de Informática
> > > Ingeniero Informático       |      Universidad Politécnica de Valencia
> > > Tlf: +34 963877237          |                        Camí de Vera, S/N
> > > cmarbur at iti.upv.es          |                   46071 Valencia - Spain
> > > www.iti.upv.es/~cmarbur     |                           www.iti.upv.es
> > > ----------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > This is the private VTK discussion list.
> > > Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> > > Follow this link to subscribe/unsubscribe:
> > > http://public.kitware.com/mailman/listinfo/vtkusers
> >
> > --
> > Malaterre, Mathieu
> > The John P. Robarts Research Institute
> > Imaging Research Laboratories
> > http://www.imaging.robarts.ca/~mmalat
> >
> >
> >
> > _______________________________________________
> > This is the private VTK discussion list.
> > Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/vtkusers
> >
>
> --
> ----------------------------------------------------------------------
> Carlos Martínez Burgos      |     Instituto Tecnológico de Informática
> Ingeniero Informático       |      Universidad Politécnica de Valencia
> Tlf: +34 963877237          |                        Camí de Vera, S/N
> cmarbur at iti.upv.es          |                   46071 Valencia - Spain
> www.iti.upv.es/~cmarbur     |                           www.iti.upv.es
> ----------------------------------------------------------------------

--
Malaterre, Mathieu
The John P. Robarts Research Institute
Imaging Research Laboratories
http://www.imaging.robarts.ca/~mmalat






More information about the vtkusers mailing list