<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Oct 19, 2017 at 11:02 AM, Edoardo Pasca <span dir="ltr"><<a href="mailto:edo.paskino@gmail.com" target="_blank">edo.paskino@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Cory, <div><br></div><div class="gmail-m_4242245585070798930cye-lm-tag">thanks for your reply. I'd love to simplify the code like that but there are 2 issues with that programmable filter</div><div><br></div><div class="gmail-m_4242245585070798930cye-lm-tag">1) I miss information on the input and output variables. Where are defined?</div></div></blockquote><div><br></div><div>It's a bit complicated to select them in the user interface, but it is possible. There was a related discussion on the mailing list recently on how to do this: <a href="http://paraview.markmail.org/thread/j4ynkclxcucpqoa5">http://paraview.markmail.org/thread/j4ynkclxcucpqoa5</a></div><div><br></div><div>In the worst case, you can hard-code the array names if they don't change. Relying on the active scalar attribute is old-style VTK and may go away someday in the not-too-near future. Or you could just keep your original code for defining array B.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail-m_4242245585070798930cye-lm-tag"></div><div class="gmail-m_4242245585070798930cye-lm-tag">2) Paraview crashes. Paraview for windows 5.4.1 and 5.3.0 (official kitware build)</div><div class="gmail-m_4242245585070798930cye-lm-tag"><br></div><div class="gmail-m_4242245585070798930cye-lm-tag">It seems a memory access problem.</div></div></blockquote><div><br></div><div>To debug, I suggest writing your Programmable Filter script a few lines at a time to determine which line causes the crash.</div><div><br></div><div>HTH,</div><div>Cory</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail-m_4242245585070798930cye-lm-tag"><br></div><div class="gmail-m_4242245585070798930cye-lm-tag">Edo</div></div><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 19, 2017 at 2:52 PM, Cory Quammen <span dir="ltr"><<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Edo,<div><br></div><div>Documentation for the VTK/Numpy adapter can be found here:</div><div><br></div><div><a href="https://www.paraview.org/ParaView/Doc/Nightly/www/py-doc/paraview.vtk.numpy_interface.html?highlight=numpy_interface#numpy-interface-package" target="_blank">https://www.paraview.org/ParaV<wbr>iew/Doc/Nightly/www/py-doc/<wbr>paraview.vtk.numpy_interface.<wbr>html?highlight=numpy_<wbr>interface#numpy-interface-<wbr>package</a><br></div><div><br></div><div>You will likely be interested in the dataset_adapter module that provides a convenient way to wrap VTK data objects in a Python class that provides easy read/write access to VTK data arrays as Numpy arrays.</div><div><br></div><div>You could simplify your code quite a bit using this adapter as in the following:</div><div><br></div><div><span><pre style="white-space:pre-wrap;margin-top:12px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">import</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,0,255)">numpy</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">from</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,0,255)">vtk.util</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">import</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> numpy_support, vtkImageImportFromArray</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">import</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,0,255)">vtk.numpy_interface.dataset_ad<wbr>apter</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">as</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,0,255)">dsa</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span></pre><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre></span><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New"">inData = dsa.WrapDataObject(inputs[0])</pre><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New"">B = inData.PointData['array_name'] # best practice is to name the array</pre><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#B </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> numpy_support</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">vtk_to_numpy(</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#                inputs[</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">0</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">]</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">GetPointData()</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">GetSc<wbr>alars())</span></pre><span><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">ifLarger </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">lambda</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> x,M: x </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">if</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> x</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)"><=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">M </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">else</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">0</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">fgt </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> numpy</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">frompyfunc(ifLarger,</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">2</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">,</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">1</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">)</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-style:italic;color:rgb(64,128,128)">#A = fgt(B,int(2**16*0.8))</span></pre><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New";font-style:italic;color:rgb(64,128,128)"><br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">ifSmaller </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">lambda</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> x,M: x </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">if</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> x</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">></span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">M </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">else</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">0</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">flt </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> numpy</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">frompyfunc(ifSmaller,</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">2</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">,</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">1</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""><wbr>)</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-style:italic;color:rgb(64,128,128)">#A = flt(B,int(2**16*0.3))</span></pre><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New";font-style:italic;color:rgb(64,128,128)"><br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">ifBetween </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">lambda</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> x,m,M: ifSmaller(x,m) </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">if</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> x</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)"><=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">M </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)">else</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">0</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">fbetw </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> numpy</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">frompyfunc(ifBetween,</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">3</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">,</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">1</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""><wbr>)</span></pre><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">A </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> fbetw(B,</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(0,128,0)">int</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">(</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">2**16*0.3</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">), </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(0,128,0)">int</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">(</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">2**16*0.95</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">))</span></pre><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre></span><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New"">outData = dsa.WrapDataObject(output)</pre><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New"">outData.PointData.append(A,'ne<wbr>w_array_name')</pre><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">#A <span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> numpy</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">asarray(A,dtype</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">uint16)</span><br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#dims </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> inputs[</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">0</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">]</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">GetDimensions()</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#A </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> numpy</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">reshape(A, (dims[</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">2</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">],dims[</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">1</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">],dims[</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">0</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">]), order</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(186,33,33)">'C'</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">)</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#A </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> numpy</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">ascontiguousarray(A)</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#importer </span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> vtkImageImportFromArray</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">vtkIma<wbr>geImportFromArray()</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#importer</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">SetArray(A)</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#importer</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">SetDataSpacing(input<wbr>s[</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">0</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">]</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">GetSpacing())</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#importer</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">SetDataOrigin(inputs<wbr>[</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">0</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">]</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">GetOrigin())</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#importer</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">Update()</span></pre><pre style="white-space:pre-wrap;font-size:12.8px;margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">#output</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">DeepCopy(importer</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">GetO<wbr>utput())</span></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span class="gmail-m_4242245585070798930m_-8002535427336090574gmail-m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""><br></span></pre>Hope that helps,<br><br>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote"><span>On Tue, Oct 17, 2017 at 10:38 AM, Edoardo Pasca <span dir="ltr"><<a href="mailto:edo.paskino@gmail.com" target="_blank">edo.paskino@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-m_4242245585070798930h5"><div dir="ltr">Hi there, <div><br></div><div>In my programmable filter I want to use numpy to perform some operations on the pixels (in this case a simple thresholding). I've come up with this solution which works. I'm wondering if there are other ways to do the conversion from numpy array to vtkImageData.</div><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"><br></div><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">in the following code I get a numpy array out of the input vtkImageData as B. Then I do something on the content an store the result in a numpy array, A. </div><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"><br></div><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">Then I convert the numpy array to a vtkImageData with vtkImageImportFromArray importer class. </div><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">Finally I copy the importer output to the output of the programmable filter.</div><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"><br></div><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">Thanks for any suggestions</div><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"><br></div><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">Edo</div><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"><pre style="margin-top:12px;margin-bottom:0px"><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">import</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,0,255)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">numpy</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">from</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,0,255)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">vtk.util</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">import</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> numpy_support, vtkImageImportFromArray</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">import</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,0,255)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">vtk.numpy_interface.dataset_ad<wbr>apter</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">as</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,0,255)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">dsa</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span></pre>
<pre style="margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">B </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> numpy_support</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">vtk_to_numpy(</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">                inputs[</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">0</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">]</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">GetPointData()</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">GetSc<wbr>alars())</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">ifLarger </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">lambda</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> x,M: x </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">if</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> x</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"><=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">M </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">else</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">0</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">fgt </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> numpy</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">frompyfunc(ifLarger,</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">2</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">,</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">1</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">)</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New";font-style:italic;color:rgb(64,128,128)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">#A = fgt(B,int(2**16*0.8))</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;font-family:"Courier New";font-style:italic;color:rgb(64,128,128)"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">ifSmaller </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">lambda</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> x,M: x </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">if</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> x</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">></span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">M </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">else</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">0</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">flt </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> numpy</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">frompyfunc(ifSmaller,</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">2</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">,</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">1</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"><wbr>)</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New";font-style:italic;color:rgb(64,128,128)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">#A = flt(B,int(2**16*0.3))</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;font-family:"Courier New";font-style:italic;color:rgb(64,128,128)"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">ifBetween </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">lambda</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> x,m,M: ifSmaller(x,m) </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">if</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> x</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"><=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">M </span><span style="font-family:"Courier New";font-weight:600;color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">else</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">0</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">fbetw </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> numpy</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">frompyfunc(ifBetween,</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">3</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">,</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">1</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"><wbr>)</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">A </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> fbetw(B,</span><span style="font-family:"Courier New";color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">int</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">(</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">2**16*0.3</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">), </span><span style="font-family:"Courier New";color:rgb(0,128,0)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">int</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">(</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">2**16*0.95</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">))</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre>
<pre style="margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre>
<pre style="margin-top:0px;margin-bottom:0px">A <span class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag" style="font-family:"Courier New""> numpy</span><span class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">.</span><span class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">asarray(A,dtype</span><span class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag" style="font-family:"Courier New";color:rgb(102,102,102)">=</span><span class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag" style="font-family:"Courier New"">uint16)</span><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">dims </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> inputs[</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">0</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">]</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">GetDimensions()</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">A </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> numpy</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">reshape(A, (dims[</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">2</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">],dims[</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">1</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">],dims[</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">0</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">]), order</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New";color:rgb(186,33,33)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">'C'</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">)</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">A </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> numpy</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">ascontiguousarray(A)</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">importer </span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">=</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"> vtkImageImportFromArray</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">vtkIma<wbr>geImportFromArray()</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">importer</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">SetArray(A)</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">importer</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">SetDataSpacing(inputs<wbr>[</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">0</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">]</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">GetSpacing())</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">importer</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">SetDataOrigin(inputs[</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag"><wbr>0</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">]</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">GetOrigin())</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">importer</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">Update()</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;font-family:"Courier New""><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">output</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">DeepCopy(importer</span><span style="font-family:"Courier New";color:rgb(102,102,102)" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">.</span><span style="font-family:"Courier New"" class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583cye-lm-tag">GetOu<wbr>tput())</span></pre><span class="gmail-m_4242245585070798930m_-8002535427336090574HOEnZb"><font color="#888888">
<pre style="margin-top:0px;margin-bottom:12px;font-family:"Courier New""><br></pre><div><br></div>-- <br><div class="gmail-m_4242245585070798930m_-8002535427336090574m_9198809036681559583gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Edo</div><div>I know you think you understand what you thought I said, but I'm not sure you realize that what you heard is not what I meant (prob. Alan Greenspan)<br>:wq</div></div></div></div></div>
</font></span></div></div>
<br></div></div><span>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" rel="noreferrer" target="_blank">http://paraview.org/Wiki/ParaV<wbr>iew</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/paraview</a><br>
<br></span></blockquote></div><span class="gmail-m_4242245585070798930HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_4242245585070798930m_-8002535427336090574gmail_signature">Cory Quammen<br>Staff R&D Engineer<br>Kitware, Inc.</div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_4242245585070798930gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Edo</div><div>I know you think you understand what you thought I said, but I'm not sure you realize that what you heard is not what I meant (prob. Alan Greenspan)<br>:wq</div></div></div></div></div>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Cory Quammen<br>Staff R&D Engineer<br>Kitware, Inc.</div>
</div></div>