[Paraview] Paraview python script: passing images to PIL (python image library)
Albina, Frank
frank.albina at sauber-motorsport.com
Wed Oct 12 14:22:12 EDT 2016
David,
this leads me to another question. Looking at file raster_wrangler.py in lib/paraview-5.1/site-packages/paraview/cinemaIO, one tries to import PIL. However, even though numpy is provided by the SuperBuild, PIL is not. So I guess that I have to compile my own version of Python including PIL and pass it to the SuperBuild as system python installation. Is my assumption correct? Or have I been missing something?
Cheers,
Frank.
From: ParaView [mailto:paraview-bounces at paraview.org] On Behalf Of Albina, Frank
Sent: Mittwoch, 12. Oktober 2016 20:01
To: David E DeMarle
Cc: Del Citto, Francesco; paraview at paraview.org
Subject: Re: [Paraview] Paraview python script: passing images to PIL (python image library)
David,
that’s excellent.
Thanks a lot.
Frank.
From: David E DeMarle [mailto:dave.demarle at kitware.com]
Sent: Mittwoch, 12. Oktober 2016 19:56
To: Albina, Frank
Cc: paraview at paraview.org<mailto:paraview at paraview.org>; Del Citto, Francesco
Subject: Re: [Paraview] Paraview python script: passing images to PIL (python image library)
Look into the cinemaIO directory of ParaView. We move back and forth between paraview, numpy and PIL often there.
For example:
image = self.view.CaptureWindow(1)
ext = image.GetExtent()
width = ext[1] - ext[0] + 1
height = ext[3] - ext[2] + 1
imagescalars = image.GetPointData().GetScalars()
idata = numpy_support.vtk_to_numpy(imagescalars)
image.UnRegister(None)
imageslice = idata.reshape(height, width, 3)
imageslice = numpy.flipud(imageslice)
pimg = PIL.Image.fromarray(imageslice)
David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909<tel:518-881-4909>
On Wed, Oct 12, 2016 at 1:42 PM, Albina, Frank <frank.albina at sauber-motorsport.com<mailto:frank.albina at sauber-motorsport.com>> wrote:
All,
A simple question: my incentive is to manipulate images using PIL in a pvbatch script. At the time being, I am writing the images to file in PNG format and reading the file again from disc using PIL. I have found out that the underlying image writing is performed by the vtkPNGWriter class and that this class allows to write to memory (vtkPNGWriter.SetWriteToMemory). Hence my question: Is it possible to “write” a PNG file to memory so that I can process it further using PIL? If so, how shall I proceed?
Thank you very much in advance.
Cheers,
Frank.
_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
Search the list archives at: http://markmail.org/search/?q=ParaView
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20161012/223a729b/attachment.html>
More information about the ParaView
mailing list