How to apply median filter on the vertices?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

How to apply median filter on the vertices?

Post by stefankorisnik3 »

I have n vertices.
I can for every vertex calculate let's say k vertices that are at the distance under some treshold.
How to apply median filter?
Do i need to look at the neighbours points like matrix k x k?
How to i define now median filter for this neighbours points?
User avatar
onekk
Veteran
Posts: 6205
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: How to apply median filter on the vertices?

Post by onekk »

Not very clear, once you have vertexes, you could calculate upon them using coordinates and calculate whatever statistic you want.

Sorry but "median" could be a "statistical concept":
https://en.wikipedia.org/wiki/Median

So it is not clear what you want to calculate.

Probably FC has no statistic computation on board.

Vertex are topological wrapper for Vectors.

You have this function that could be useful:

Code: Select all

help(FreeCAD.Vector.distanceToPoint)
You could think to calculate some values using the mean point and then order them using the distanceToPoint and find the point that "divide the distribution" in two parts (The Median).

But I don0t know if this is what you intend to calculate.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Re: How to apply median filter on the vertices?

Post by stefankorisnik3 »

I have some sharp peaks in the generated model and have seen in this article
that i can apply them on the faces of the triangles: https://www.researchgate.net/publicatio ... l_surfaces

Currently i dont have triangles (can i get automatically triangles in FreeCAD, can i triangulate between points with some tool)
Currently i have just loft between some curves, and the tool loft give me the rectangles between the vertices.
So i'm currently splitting that rectangles into two triangles so i can apply median filter like in this article.

But i want to ask how can i apply median filter on the neighbours of vertices?
How do i generate the subsurface that those vertices construct and then smooth that subsurface with median filter?
User avatar
onekk
Veteran
Posts: 6205
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: How to apply median filter on the vertices?

Post by onekk »

stefankorisnik3 wrote: Mon Aug 01, 2022 2:50 pm I have some sharp peaks in the generated model and have seen in this article
that i can apply them on the faces of the triangles: https://www.researchgate.net/publicatio ... l_surfaces

Currently i dont have triangles (can i get automatically triangles in FreeCAD, can i triangulate between points with some tool)
Currently i have just loft between some curves, and the tool loft give me the rectangles between the vertices.
So i'm currently splitting that rectangles into two triangles so i can apply median filter like in this article.

But i want to ask how can i apply median filter on the neighbours of vertices?
How do i generate the subsurface that those vertices construct and then smooth that subsurface with median filter?
In FC you are not dealing with triangulations, until you export it as meshes, faces are made as continous curves, so probably it is not a good strategy in FC.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: How to apply median filter on the vertices?

Post by heda »

it is very unclear what your starting point is and where you want to go...

I have n faces with sharp corners :-), yeah, that also I can do, it is just to make a box....
a picture is worth more than a thousand words.

anyhow, it seems like you are more into meshing and those algorithms compared to brep modelling (fc happens to be brep and not meshing).

a facet on a mesh is not the same as a face, a face is a brep, a facet in a mesh-object is a triangle (formulated in a suitable way for mesh topologies, i.e. index of 3 points - order decides normal...)

have you come across https://www.meshlab.net/?
that has the filters that you are looking for without coding them yourself, you just have to export a mesh and get going.

anyhow, some basics in the attached file
- a box split into faces (this is brep-shapes)
- mesh wb/shape 2 mesh (mefisto in this case) on all faces (now it is a triangulated mesh)
- merge meshes
- copy the merged
- analyse copy, fix duplicate points (that is the last object in the file), in this case it was lucky, no gaps and no self-intersections, that will not always be the case when meshing separate faces and merging the meshes.

probably won't hurt to read some of the docs for different commands.
Attachments
somebasics.FCStd
(75.69 KiB) Downloaded 11 times
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Re: How to apply median filter on the vertices?

Post by stefankorisnik3 »

Thanks
Post Reply