[vtkusers] Fwd: How to smooth (or filter) polydata scalars?

Fabio Meneghini fab.meneghini at gmail.com
Sun Jan 18 05:04:05 EST 2009


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/20090118/1e6d6e7b/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/20090118/1e6d6e7b/attachment.cxx>


More information about the vtkusers mailing list