Skip to content

Commit ca89949

Browse files
committed
Merge pull request #5597 from lrineau/Mesh_3-weighted_images-GF
Mesh_3: Add weighted images
2 parents 50f30df + caa8c74 commit ca89949

26 files changed

+819
-41
lines changed

BGL/include/CGAL/boost/parameter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ BOOST_PARAMETER_NAME( (pointer_to_stop_atomic_boolean, tag ) pointer_to_stop_ato
110110
BOOST_PARAMETER_NAME( (function, tag ) function_)
111111
BOOST_PARAMETER_NAME( (bounding_object, tag ) bounding_object_)
112112
BOOST_PARAMETER_NAME( (relative_error_bound, tag ) relative_error_bound_)
113+
BOOST_PARAMETER_NAME( (weights, tag) weights_)
113114
BOOST_PARAMETER_NAME( (p_rng, tag ) p_rng_)
114115
BOOST_PARAMETER_NAME( (null_subdomain_index, tag ) null_subdomain_index_)
115116
BOOST_PARAMETER_NAME( (construct_surface_patch_index, tag ) construct_surface_patch_index_)

CGAL_ImageIO/include/CGAL/Image_3.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class CGAL_IMAGEIO_EXPORT Image_3
103103
// std::cerr << "Image_3::copy_constructor\n";
104104
}
105105

106-
Image_3(_image* im, Own own_the_data = OWN_THE_DATA)
106+
explicit Image_3(_image* im, Own own_the_data = OWN_THE_DATA)
107107
{
108108
private_read(im, own_the_data);
109109
}
@@ -147,9 +147,9 @@ class CGAL_IMAGEIO_EXPORT Image_3
147147
double vy() const { return image_ptr->vy; }
148148
double vz() const { return image_ptr->vz; }
149149

150-
double tx() const { return image_ptr->tx; }
151-
double ty() const { return image_ptr->ty; }
152-
double tz() const { return image_ptr->tz; }
150+
float tx() const { return image_ptr->tx; }
151+
float ty() const { return image_ptr->ty; }
152+
float tz() const { return image_ptr->tz; }
153153

154154
float value(const std::size_t i,
155155
const std::size_t j,
@@ -158,6 +158,11 @@ class CGAL_IMAGEIO_EXPORT Image_3
158158
return ::evaluate(image(),i,j,k);
159159
}
160160

161+
bool is_valid() const
162+
{
163+
return image_ptr.get() != nullptr;
164+
}
165+
161166
public:
162167

163168
bool read(const char* file)

Documentation/doc/biblio/cgal_manual.bib

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3256,6 +3256,12 @@ @article{cgal:Wwshap-eepec-20
32563256
publisher = {ACM}
32573257
}
32583258

3259+
@article{stalling1998weighted,
3260+
title={Weighted labels for 3D image segmentation},
3261+
author={Stalling, Detlev and Z{\"o}ckler, Malte and Sander, Oliver and Hege, Hans-Christian},
3262+
year={1998}
3263+
}
3264+
32593265
% ----------------------------------------------------------------------------
32603266
% END OF BIBFILE
32613267
% ----------------------------------------------------------------------------
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if(ITK_FOUND AND NOT TARGET CGAL::ITK_support)
2+
add_library(CGAL::ITK_support INTERFACE IMPORTED)
3+
set_target_properties(CGAL::ITK_support PROPERTIES
4+
INTERFACE_COMPILE_DEFINITIONS "CGAL_USE_ITK"
5+
INTERFACE_INCLUDE_DIRECTORIES "${ITK_INCLUDE_DIRS}"
6+
INTERFACE_LINK_LIBRARIES "${ITK_LIBRARIES}")
7+
endif()

Installation/cmake/modules/list_of_whitelisted_headers.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ set(list_of_whitelisted_headers_txt [=[
4141
CGAL/IO/Triangulation_geomview_ostream_3.h
4242
CGAL/IO/Triangulation_geomview_ostream_2.h
4343
CGAL/IO/Polyhedron_geomview_ostream.h
44-
44+
CGAL/Mesh_3/generate_label_weights.h
4545
]=])
4646

4747
separate_arguments(list_of_whitelisted_headers UNIX_COMMAND ${list_of_whitelisted_headers_txt})

Mesh_3/doc/Mesh_3/CGAL/Labeled_mesh_domain_3.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ The parameters are optional unless otherwise specified.
233233
<li> <b>`parameters::image` (mandatory)</b> the input 3D image. Must
234234
be a `CGAL::Image_3` object.
235235
236+
<li> <b>`parameters::weights`</b> an input 3D image that provides
237+
weights associated to each voxel (the word type is `unsigned char`,
238+
and the voxels values are integers between 0 and 255).
239+
The weights image can be generated with `CGAL::Mesh_3::generate_label_weights()`.
240+
Its dimensions must be the same as the dimensions of `parameters::image`.
241+
236242
<li><b>`parameter::value_outside`</b> the value attached to voxels
237243
outside of the domain to be meshed. Its default value is `0`.
238244
@@ -246,6 +252,11 @@ From the example (\ref Mesh_3/mesh_3D_image.cpp):
246252
247253
\snippet Mesh_3/mesh_3D_image.cpp Domain creation
248254
255+
From the example (\ref Mesh_3/mesh_3D_weighted_image.cpp),
256+
where the labeled image is used with a precomputed 3D image of weights :
257+
258+
\snippet Mesh_3/mesh_3D_weighted_image.cpp Domain creation
259+
249260
*/
250261
template <typename ... A_i>
251262
static

Mesh_3/doc/Mesh_3/Doxyfile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ ALIASES += "cgalDescribePolylineType=A polyline is defined as a sequence of poin
55

66
INPUT += \
77
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Polyhedral_complex_mesh_domain_3.h \
8-
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Mesh_domain_with_polyline_features_3.h
8+
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Mesh_domain_with_polyline_features_3.h \
9+
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Mesh_3/generate_label_weights.h
910

1011
PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 3D Mesh Generation"
1112
HTML_EXTRA_FILES = ${CGAL_PACKAGE_DOC_DIR}/fig/implicit_domain_3.jpg \

Mesh_3/doc/Mesh_3/Mesh_3.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,24 @@ The resulting mesh is shown in \cgalFigureRef{figureliver_3d_image_mesh}.
706706
Cut view of a 3D mesh produced from a segmented liver image. Code from subsection \ref Mesh_3_subsection_examples_3d_image generates this file.
707707
\cgalFigureEnd
708708

709+
\subsubsection Mesh_3DomainsFrom3DImagesWithWeights Domains From Segmented 3D Images, with Weights
710+
711+
When a segmented image is given as input, the generated mesh surface sometimes sticks too closely
712+
to the voxels surface, causing an aliasing effect.
713+
A solution to generate a smooth and accurate output surface was described by Stalling et al in
714+
\cgalCite{stalling1998weighted}. It consists in generating a second input image, made
715+
of integer coefficients called *weights*, and use those weights to define smoother domain boundaries.
716+
The 3D image of weights can be generated using `CGAL::Mesh_3::generate_weights()` as shown in
717+
the following example.
718+
719+
\cgalExample{Mesh_3/mesh_3D_weighted_image.cpp}
720+
721+
\cgalFigureBegin{figure_weightedImage, weighted_images.jpg}
722+
Surface of the output mesh generated with a very small `facet_distance`
723+
without the weights (left, 25563 vertices) and with the weights (right, 19936 vertices).
724+
\cgalFigureEnd
725+
726+
709727
\subsubsection Mesh_3DomainsFrom3DImagesWithCustomInitialization Domains From 3D Images, with a Custom Initialization
710728

711729
The example \ref Mesh_3/mesh_3D_image_with_custom_initialization.cpp is a modification

Mesh_3/doc/Mesh_3/PackageDescription.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ and their associated classes:
115115
- `CGAL::lloyd_optimize_mesh_3()`
116116
- `CGAL::odt_optimize_mesh_3()`
117117
- `CGAL::facets_in_complex_3_to_triangle_mesh()`
118+
- `CGAL::Mesh_3::generate_label_weights()`
118119

119120
\cgalCRPSection{CGAL::parameters Functions}
120121

Mesh_3/doc/Mesh_3/examples.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
\example Mesh_3/mesh_3D_gray_image_with_custom_initialization.cpp
55
\example Mesh_3/mesh_3D_image_with_features.cpp
66
\example Mesh_3/mesh_3D_image_with_custom_initialization.cpp
7+
\example Mesh_3/mesh_3D_weighted_image.cpp
78
\example Mesh_3/random_labeled_image.h
89
\example CGAL/Mesh_3/initialize_triangulation_from_gray_image.h
910
\example CGAL/Mesh_3/initialize_triangulation_from_labeled_image.h

0 commit comments

Comments
 (0)