[vtkusers] How do I interpolate scalars along the geometric surface?

Fabio Meneghini fab.meneghini at gmail.com
Wed Feb 18 16:49:48 EST 2009


Hi!
few weeks ago I faced almost the same kind of problem.
The piece of source code I wrote, in C++, act as a moving average
filter across the surface. The average is weighted by the distance
between the current point and his neighbors. It's quite slow during
the execution, since no optimization has been performed (I'm always in
short time...).
I'm not sure this is what you need, since you have to interpolate
scalars across a surface, which is a complete different thing, but I
hope this could be of inspiration for you.
Good luck!

Fabio




---------- Forwarded message ----------
From: Fabio Meneghini <fab.meneghini at gmail.com>
Date: 2009/1/18
Subject: Re: [vtkusers] Fwd: How to smooth (or filter) polydata scalars?
To: "Kevin H. Hobbs" <hobbsk at ohiou.edu>, vtkusers at vtk.org


To whom it may concern,
Thanks to help from Kevin H. Hobbs, I wrote a routine performing
PolyData scalar values smoothing.

That is, it takes as the actual point value the mean of the neighbor
points values (but including also himself) , weighting their values
mean by the RATIO of their distance from the actual point AND a
maximum tolerance distance.
Specifically, It takes into account the current point value, with
maximum weighting (that is 1), and the neighbors points values with
weighting equal to (1 - d/dmax). This only if d<dmax, otherwise the
weighting for that point is null.

Please, I would be glad if anyone could give a look at this algorithm:
it could be implemented as a method (or even a class). It's working
fine for my purposes, but I think it's not very much optimized, since
I'm not exactly a hero in programming, yet, so fell free to suggest me
how to boost and improve performances...
I wrote both the C++ and TCL  versions, of the algorithm, so you don't
have excuses! ^__^ Have fun!!!

Fabio Meneghini


2009/1/14 Kevin H. Hobbs <hobbsk at ohiou.edu>
>
> On Wed, 2009-01-14 at 13:38 +0100, Fabio Meneghini wrote:
> >
> > Thank you very much for your reply. I really appreciated it!
>
> You're welcome.
>
> > So, for every vertex of the polydata,
>
> "Vertex" has a specific meaning in VTK it means a cell with one point.
> I'm not much of a jargon nut but this could prevent some confusion as
> you search through classes.
>
> >   I could compute the mean of the scalar values of its neighbors
> > (possibly with some weights, depending on their distance from the
> > current vertex, and then replace the actual scalar value of current
> > vertex with the mean.
>
> In general yes that's how I'd do it. Do the replacement in a temporary
> scalar array or calculate the average from a copy of the scalar array.
> That way you won't contaminate the average of the neighbors of later
> points with the average of the neighbors of earlier points.
>
> > waiting for a better suggestion about wich classes do this job
> > better,
> > Thanks again for the hint...
> >
>
> Use of the gradient or gradient magnitude filters might help you with
> highpass filters.
>
> > Fabio
>
> I'm attaching code that does point (position) smoothing in a particular
> way that I need. It should help you walk the polydata.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SmoothPolyDataScalars.tcl
Type: application/x-tcl
Size: 2423 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090218/fae55ec9/attachment.tcl>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smooth_map.cxx
Type: text/x-c++src
Size: 3751 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090218/fae55ec9/attachment.cxx>


More information about the vtkusers mailing list