Surface smoothing of 2D/3D objects

Hello,
starting from a segmented object (2D/3D) I would like to smooth it. Often the segmented object looks pretty rough and one knows that the physical object is rather smooth.
Ideally creating a mesh on an object and then let the mesh evolve according to some physical/energy minimization constraints to create a smooth mesh. Level-sets?

Don’t know exactly how to do it but some of you may have other ideas or specific tools to use.

Thanks for any suggestions

Antonoo

Hello Antonoo,
assuming that your segmentations are bitmap images, the easiest way is to apply gaussian smoothing filter to it. You can do it in both 2d or 3d. Smoothing of meshes is an alternative solution, but it requires more steps.
Best regards,
Ilya

Hi @apoliti,

Usually for surface smoothing I use 3DViewer. Simply import the binary image using surface, then right click on the object and select smooth control.

Best

Thomas

Hello @ThomasBoudier, hello @Ilya_Belevich,
Thanks for your answers, yes the image is a bitmap.
The gaussian smoothing will work and I could resample the bitmap before doing this (the original image from which I extracted the bitmap was undersampled in Z).
I will also try the surface smoothing. I think the 3DViewer smoothing does not use any physical constraints? Like minimization of surface curvature?

Antonio

An animated gif of the segmented object (two nuclei touching each other) segmented using the fiji CATS plugin from @Christian_Tischer.

tif_foreground_bin

The link to the binary for completion

Here is the code from 3DViewer:

smooth2 has a description and in the authors list it mentions @albertcardona, maybe he can explain you more what this actually does.

To use those functions you first have to create a mesh from your binary image. The code for this must be somewhere in the repo: https://github.com/fiji/3D_Viewer/tree/master/src/main/java
You could probably find it by cloning the repo and then searching for functions that call the marching cubes functions: https://github.com/fiji/3D_Viewer/tree/master/src/main/java/marchingcubes.
If you need help there I can also have a look.

To go then back from the smoothed mesh to an image you probably just loop through the point list of the mesh and paint them into an image? @ThomasBoudier, how are you doing this?

1 Like

Indeed, @apoliti @Christian_Tischer, the 3D smoothing from the “Smooth control” dialog in the 3D Viewer is the exact same algorithm that Blender uses, and is entirely geometric, by averaging the position of vertices that are part of a triangle.

Hi all,

@apoliti The only software that I am aware of working on curvature minimization is SurfaceEvolver . Since you are interested in surfaces you can have a look at LimeSeg too.

@Christian_Tischer There is a function getVoxels within the class Object3DSurface, it is not well documented but it should work.

1 Like

I read the layers from the tiff image, extracting the points of the contour. This results in a list of 3D points that I converted to PLY format to import them in Meshlab. This free software is able to reconstruct a smooth surface from a point-cloud. The filters needed are “Normals > Compute Normals for point set” and “Remeshing > Surface Reconstruction: Poisson”. After playing for a while, 50 neighbors were fine in the first filter and (7,7,2,1) parameters in the second. The resulting surface is inverted so I used the filter “Normals > Invert Faces Orientation”. Meshlab can be scripted to automate this process.

surface.zip (49.3 KB)

MeshLab

2 Likes

looks pretty thanks.
I will now try some of the alternatives.

Hi @albertcardona,
somehow the smooth control does not appear in the windows version. What am I missing? Are there several 3D Image viewers?

Thanks
Antonio

@albertcardona
I found the control.
Right click mouse

Hello @B0RJA,
I was able to load a file from 3D viewer in Meshlab (stl format). I was not able to find a quick way to generate a ply file. The command “Remeshing > Surface Reconstruction: Poisson” has been probably removed. In the menu I can only find “Surface Reconstruction: Ball Pivoting” or VCG. I think in the latest version of the software “Surface Reconstruction: Poisson” has been removed. The new function as many more parameters and honestly I understand to little about this.

Unfortuntaley I can’t reproduce your results. It creates a lot of spurious vertices at the the 2 ends also using the ply files you uploaded.

thanks
Antonio

Try to reproduce the results with my .ply file using an old version of Meshlab (v1.3.2) available here.

The PLY is a simple ASCII file with a header and a list of point coordinates (of the border). The two first coordinates are the (x, y) of the pixels and the last a z coordinate is related to the spacing between images.

ply
format ascii 1.0
comment VCGLIB generated
element vertex 1719
property float x
property float y
property float z
element face 0
property list uchar int vertex_indices
end_header 
272.70 235.70 75.00
275.28 235.28 75.00
279.02 235.08 75.00
...
223.49 191.95 300.00

In my test I used a smoothing function to obtain sub-pixel resolution of the border path but I think It is not strictly necessary and the Meshlab filters will smooth anyway.

1 Like