Re: [Paraview] Paraview python script: passing images to PIL (python image library)

2016-10-12 Thread David E DeMarle
Unless you can rely on PIL being on the system search path yes.

In my case PIL is mostly optional so if you look closely you will see paths
that avoid PIL if not present when Catalyst writes out cinema files.



David E DeMarle
Kitware, Inc.
R Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Wed, Oct 12, 2016 at 2:22 PM, Albina, Frank <
frank.alb...@sauber-motorsport.com> wrote:

> 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-boun...@paraview.org] *On Behalf Of *Albina,
> Frank
> *Sent:* Mittwoch, 12. Oktober 2016 20:01
> *To:* David E DeMarle
> *Cc:* Del Citto, Francesco; paraview@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.dema...@kitware.com
> <dave.dema...@kitware.com>]
> *Sent:* Mittwoch, 12. Oktober 2016 19:56
> *To:* Albina, Frank
> *Cc:* paraview@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 Engineer
> 21 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909
>
>
>
> On Wed, Oct 12, 2016 at 1:42 PM, Albina, Frank <frank.albina@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
>
> 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
>
>
>
___
Powered by 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


Re: [Paraview] Paraview python script: passing images to PIL (python image library)

2016-10-12 Thread Albina, Frank
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-boun...@paraview.org] On Behalf Of Albina, Frank
Sent: Mittwoch, 12. Oktober 2016 20:01
To: David E DeMarle
Cc: Del Citto, Francesco; paraview@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.dema...@kitware.com]
Sent: Mittwoch, 12. Oktober 2016 19:56
To: Albina, Frank
Cc: paraview@paraview.org<mailto:paraview@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 Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Wed, Oct 12, 2016 at 1:42 PM, Albina, Frank 
<frank.alb...@sauber-motorsport.com<mailto:frank.alb...@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

___
Powered by 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


Re: [Paraview] Paraview python script: passing images to PIL (python image library)

2016-10-12 Thread Albina, Frank
David,

that’s excellent.

Thanks a lot.
Frank.
From: David E DeMarle [mailto:dave.dema...@kitware.com]
Sent: Mittwoch, 12. Oktober 2016 19:56
To: Albina, Frank
Cc: paraview@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 Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Wed, Oct 12, 2016 at 1:42 PM, Albina, Frank 
<frank.alb...@sauber-motorsport.com<mailto:frank.alb...@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

___
Powered by 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


Re: [Paraview] Paraview python script: passing images to PIL (python image library)

2016-10-12 Thread David E DeMarle
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 Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Wed, Oct 12, 2016 at 1:42 PM, Albina, Frank  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
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensou
> rce/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
>
>
___
Powered by 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


[Paraview] Paraview python script: passing images to PIL (python image library)

2016-10-12 Thread Albina, Frank
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

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