Skip to content

Commit

Permalink
Merge pull request #306 from dcoeurjo/regularization
Browse files Browse the repository at this point in the history
Regularization
  • Loading branch information
kerautret committed Mar 16, 2018
2 parents 72f2ca8 + 5a6c4e7 commit 4d6f99b
Show file tree
Hide file tree
Showing 13 changed files with 1,334 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
(Bertrand Kerautret, [#285](https://github.com/DGtal-team/DGtalTools/pull/285))
- tangentBC: add an option to read sdp points as input.
(Bertrand Kerautret, [#285](https://github.com/DGtal-team/DGtalTools/pull/288))
- volSurfaceRegularization: a tool to compute a regularized quadrangulation from
from a digital surface.
(Pierre Gueth, David Coeurjolly, [#306](https://github.com/DGtal-team/DGtalTools/pull/306))


# DGtalTools 0.9.2
Expand Down
19 changes: 10 additions & 9 deletions doc/estimators.dox
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file estimators.dox
* @author Bertrand Kerautret
* @author Bertrand Kerautret
* LORIA (CNRS, UMR 7503), University of Lorraine, France
*
* @date 2016/05/12
Expand All @@ -20,38 +20,39 @@


- @ref Doc2dLocalEstimators : compares local estimators on implicit shapes using DGtal Library.
- @ref Doc3dCurveTangentEstimator : estimates the tangent vector to a set of 3D integer points.
- @ref Doc3dCurveTangentEstimator : estimates the tangent vector to a set of 3D integer points.
- @ref curvatureBC : estimates curvature using a binomial convolver.
- @ref curvatureMCMS : estimates curvature using length of most centered segment computers.
- @ref curvatureScaleSpaceBCC : generates the Curvature Scale Space image using a binomial convolver based estimator.
- @ref eulerCharacteristic : computes the Euleur Characteristic of a vol to a 8-bit raw file.
- @ref eulerCharacteristic : computes the Euleur Characteristic of a vol to a 8-bit raw file.
- @ref generic3dNormalEstimators : computes a normal vector field over a digitized 3D implicit surface for several estimators.
- @ref lengthEstimators : generates multigrid length estimations of paramteric shapes using DGtal library.
- @ref statisticsEstimators : computes satistics (L1, L2, Loo) from results of two estimators.
- @ref tangentBC : estimates tangent using a binomial convolver.
- @ref vol2normalField : generates normal vector field from a vol file using DGtal library.
- @ref volSurfaceRegularization : regularizes a digital surface into a smooth cubical complex.



<center>
<table>
<tr>
<td> <img height=200px src="res2dLocalEstimators.png"> </td>
<td><img height=200px src="res3dCurveTangentEstimator.png"></td>
<td><table> <tr><td><img height=50px src="resCurvatureBCcontour.png"></td><td><img height=200px src="resCurvatureBCcurvature.png"></td></tr></table></td>
<td><table> <tr><td><img height=50px src="resCurvatureBCcontour.png"></td><td><img height=200px src="resCurvatureBCcurvature.png"></td></tr></table></td>
</tr>
<tr>
<td align = center>@ref Doc2dLocalEstimators </td>
<td align = center>@ref Doc3dCurveTangentEstimator </td>
<td align = center>@ref Doc3dCurveTangentEstimator </td>
<td align = center>@ref curvatureBC</td>
</tr>
<tr>
<td> <img height=200px src="resVol2normalField.png"> </td>
<td><img height=200px src="resGeneric3dNormalEstimatorsVCM.png"></td>
<td><img height=100px src="resCurvatureScaleSpaceBCC.png"></td>
<td><img height=100px src="resCurvatureScaleSpaceBCC.png"></td>
</tr>
<tr>
<td align = center>@ref vol2normalField </td>
<td align = center>@ref generic3dNormalEstimators </td>
<td align = center>@ref generic3dNormalEstimators </td>
<td align = center>@ref curvatureScaleSpaceBCC</td>
</tr>

Expand All @@ -60,4 +61,4 @@
</center>


*/
*/
Binary file added doc/images/bunny_cubical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/bunny_smooth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion estimators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ SET(DGTAL_TOOLS_SRC
eulerCharacteristic
)

if (WITH_EIGEN)
add_executable(volSurfaceRegularization volSurfaceRegularization.cpp volSurfaceRegularization-details/surface_approx.cpp)
target_link_libraries(volSurfaceRegularization ${DGTAL_LIBRARIES} ${DGtalToolsLibDependencies})
endif()

if ( WITH_VISU3D_QGLVIEWER )
SET(VISU3D_TESTS_SRC
3dCurveTangentEstimator
Expand All @@ -23,7 +28,7 @@ endif ( WITH_VISU3D_QGLVIEWER )

if ( WITH_CGAL )
SET(CGAL_TESTS_SRC
# 3dLocalEstimators
# 3dLocalEstimators
)
FOREACH(FILE ${CGAL_TESTS_SRC})
add_executable(${FILE} ${FILE})
Expand Down
141 changes: 141 additions & 0 deletions estimators/volSurfaceRegularization-details/shape.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#pragma once

#include <DGtal/base/Common.h>
#include <DGtal/math/linalg/EigenSupport.h>

struct RoundedCubeShape
{
typedef DGtal::Z3i::Point Point;
typedef Eigen::Vector3d Vector;
typedef Eigen::Matrix3d Matrix;

RoundedCubeShape(const Matrix& transform_, const double& size_, const double& radius_) : transform(transform_), size(size_), radius(radius_)
{
ASSERT( radius < size );
}

bool operator()(const Point& point) const
{
const Vector vector_(point[0], point[1], point[2]);
Vector vector = transform*vector_;
vector = vector.cwiseAbs();
if (vector.maxCoeff() <= size-radius) return true;
Vector projected = vector;
for (int kk=0; kk<projected.size(); kk++)
if (projected[kk] > size-radius)
projected[kk] = size-radius;
return (vector-projected).norm() <= radius;
}

Matrix transform;
double size;
double radius;
};

struct TorusShape
{
typedef DGtal::Z3i::Point Point;
typedef Eigen::Vector3d Vector;
typedef Eigen::Matrix3d Matrix;

TorusShape(const Matrix& transform_, const double& radius_large_, const double& radius_small_) : transform(transform_), radius_large(radius_large_), radius_small(radius_small_)
{
ASSERT( radius_small < radius_large );
}

bool operator()(const Point& point) const
{
const Vector vector_(point[0], point[1], point[2]);
const Vector vector = transform*vector_;
Vector projected = vector;
projected[1] = 0;
if (projected.norm() == 0) return false;
projected *= radius_large/projected.norm();
return (vector-projected).norm() <= radius_small;
}

Matrix transform;
double radius_large;
double radius_small;
};

struct SphereShape
{
typedef DGtal::Z3i::Point Point;
typedef DGtal::Z3i::RealPoint RealPoint;

SphereShape(const double& radius_, const RealPoint& center_) : radius(radius_), center(center_)
{
}

bool operator()(const Point& point) const
{
return (point-center).norm() <= radius;
}

double radius;
RealPoint center;
};

struct CapsuleShape
{
typedef DGtal::Z3i::Point Point;
typedef DGtal::Z3i::RealPoint RealPoint;

CapsuleShape(const double& radius_, const double& length_, const RealPoint& direction_) : radius(radius_), length(length_), direction(direction_)
{
if (direction.norm() > 0) direction /= direction.norm();
}

bool operator()(const Point& point) const
{
double alpha = direction.dot(point);
if (alpha > length/2) alpha = length/2;
if (alpha < -length/2) alpha = -length/2;
return (point-alpha*direction).norm() <= radius;
}

double radius;
double length;
RealPoint direction;
};

template <typename ImageType>
struct ImageShape
{
typedef typename ImageType::Point Point;
typedef Eigen::Vector3d Vector;
typedef Eigen::Matrix3d Matrix;

ImageShape(const ImageType* image_, const Point& shift_) : image(image_), shift(shift_)
{
ASSERT( image );
}

bool operator()(const Point& point_) const
{
const Point point = point_+shift;
if (!image->domain().isInside(point)) return false;
return (*image)(point) > 0;
}

const ImageType* image;
Point shift;
};

struct PlaneShape
{
typedef DGtal::Z3i::Point Point;
typedef DGtal::Z3i::RealPoint RealPoint;

PlaneShape(const RealPoint& normal_) : normal(normal_)
{
}

bool operator()(const Point& point) const
{
return normal.dot(point) <= 0;
}

RealPoint normal;
};
Loading

0 comments on commit 4d6f99b

Please sign in to comment.