[vtkusers] Writing renderwindow to an image

K.R.Subramanian krs at cs.uncc.edu
Thu Jul 4 11:45:26 EDT 2002


Carlos Martínez Burgos wrote:

> OK, thanks.
>
> It's a good solution at this moment. If somebody has another idea I will
> apreciate it.
>
> Thanks again.
>
> On Thu, 4 Jul 2002, Mathieu Malaterre wrote:
>
> > Hi Carlos,
> >   You can use: vtkImageData::GetScalarComponentAsFloat
> > See:
> > http://public.kitware.com/VTK/doc/nightly/html/classvtkImageData.html#a56
> >

As per the docs, this is a convenience method for use with tcl.  If we are talking
about 2D image canvases, then the simplest solution is to get the data component,
as


image_data->GetOutput()->GetScalars()

which is a pointer to the scalars array, and then get the 3 components at each
location in row major order. I would assume this is a data array with 3 components.
The coordinates are implicit because of its a regular grid.

    -- krs

>
> > 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
> >
> >
> >
>
> --
> ----------------------------------------------------------------------
> 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

--
K.R.Subramanian                        Phone: (704) 687-4872
Department of Computer Science         FAX:   (704) 687-4893
UNC Charlotte, CARC 311                Email: krs at cs.uncc.edu
Charlotte, NC 28223-0001               Web: http://www.cs.uncc.edu/~krs






More information about the vtkusers mailing list