[vtk-developers] A vtkDataSampler and image interpolation

David Gobbi david.gobbi at gmail.com
Tue Jul 5 10:12:21 EDT 2011


Hi John,

For new interpolation strategies, my intent is that people would write
their own subclasses for vtkDataSampler, i.e. vtkDataSampler provides
the abstract interface and subclasses would implement specific
strategies.  But I heartily agree that the class should have a method
that probes a list of points in one go:

virtual void vtkDataSampler::SamplePoints(vtkPoints *points,
vtkDataArray *outputScalars);

 - David


On Tue, Jul 5, 2011 at 7:41 AM, Biddiscombe, John A. <biddisco at cscs.ch> wrote:
> I think it would in general make a nice abstraction - I could for example add my meshless interpolation code as a method
>
> https://hpcforge.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=pv-meshless/pv-meshless.git;a=blob;f=vtkSPHProbeFilter.h;h=25053f9c5341d5261e04415b0335abed20e42546;hb=4fba98e0cff502d25f620e03f6982721566e2bea
>
> I think the interface might need some enhancements. For example to probe a list of points in one go. The SPH kernel evaluation uses neighbour lists and they are expensive to compute - doing multiple samples at the same time (sharing neighbours) would be an option. For most cases, an entire dataset/region/block of sample locations on each pass.
>
> I'd opt for a vtkSamplingStrategy method which would be set on the DataSampler, specific subclasses being your image (nearestneighbour,cubic,...), my SPHKernel, etc etc implementations. The strategy classes would contain their own set/get ivars for detailed controls.
>
>
> JB
>
> -----Original Message-----
> From: vtk-developers-bounces at vtk.org [mailto:vtk-developers-bounces at vtk.org] On Behalf Of David Gobbi
> Sent: 05 July 2011 14:27
> To: Will Schroeder
> Cc: VTK Developers
> Subject: Re: [vtk-developers] A vtkDataSampler and image interpolation
>
> Hi Will,
>
> If I modified the vtkProbeFilter to use the vtkDataSampler, it would
> allow people to customize the way that vtkProbeFilter interpolates the
> data.
>
> The interface would look like this: a SetDataSampler() method would be
> added to vtkProbeFilter
>
> void vtkProbeFilter::SetDataSampler(vtkDataSampler *);
>
> The probe filter would have a default vtkDataSampler object which
> would use FindCell to interpolate the data (much like the way
> vtkProbeFilter works now).  But here is where the magic comes.  The
> user would be able to provide a different data sampler:
>
> vtkImageSampler *isample = vtkImageSampler::New();
> probeFilter->SetDataSampler(isample);
>
> The vtkImageSampler is for image data, it has interpolation code that
> is specifically written for structured data and is orders of magnitude
> faster than using FindCell to interpolate the data.  Also, it provides
> the option of choosing different interpolation modes: nearest, linear,
> and cubic.
>
> So, in a nutshell, adding a SetDataSampler() method would make it
> possible for users to customize the way that vtkProbeFilter
> interpolates values from its Input.  The use of vtkImageSampler here
> is just one example, if a person needs to use vtkProbeFilter on an FEM
> data set and knows of an efficient way to interpolate their FEM, then
> they could write a vtkDataSampler class specifically for their FEM.
>
> Another way to describe my goal is as follows: I have a whole bunch of
> image interpolation code that I've written and tweaked over the past
> 10+ years, and I want to be able to use this interpolation code with
> the VTK graphics pipeline.  The vtkDataSampler class is how I hope to
> achieve this.
>
>  - David
>
>
> On Tue, Jul 5, 2011 at 3:49 AM, Will Schroeder
> <will.schroeder at kitware.com> wrote:
>> David-
>> What's the relationship of this vtkDataSampler class to the vtkProbeFilter?
>> W
>>
>> On Mon, Jul 4, 2011 at 1:23 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>
>>> Hi All,
>>>
>>> I've written some new interpolation classes for VTK, both for images
>>> and for other data sets.  One thing that I want to ensure is that the
>>> abstract interface is something that people will be satisfied with.
>>> I use the same ScalarMode constants as vtkMapper, but there might
>>> be a better way of selecting arrays that I am not aware of:
>>>
>>> class vtkDataSampler : public vtkObject
>>> {
>>>  // set the data to interpolate (does not establish pipeline connection)
>>>  void SetInput(vtkDataObject *);
>>>
>>>  // update any internal state variables prior to commencing interpolation
>>>  void Update();
>>>
>>>  // get an interpolated value, return "false" if out of bounds
>>>  bool GetSample(const double point[3], double *value);
>>>
>>>  // get an interpolated value (meant for use by wrapper languages)
>>>  double GetSample(double x, double y, double z, int component);
>>>
>>>  // set the scalar mode (same as vtkMapper scalar modes)
>>>  void SetScalarMode(int mode);
>>>  void SetScalarModeToDefault();
>>>  void SetScalarModeToUsePointData();
>>>  void SetScalarModeToUseCellData();
>>>  void SetScalarModeToUsePointFieldData();
>>>  void SetScalarModeToUseCellFieldData();
>>>
>>>  // set the array, if chosen scalar mode is field data
>>>  void SetArrayName(const char *name);
>>>
>>>  void SetTolerance(double);
>>>  void SetLocator(vtkLocator *locator);
>>> };
>>>
>>> The changes are on gerrit, if people want to see the full implementation:
>>> http://review.source.kitware.com/2004
>>>
>>>  - David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>



More information about the vtk-developers mailing list