|
a |
|
b/src/weingartenImageCurvature.cxx |
|
|
1 |
|
|
|
2 |
#include <nanobind/nanobind.h> |
|
|
3 |
#include <nanobind/stl/vector.h> |
|
|
4 |
#include <nanobind/stl/string.h> |
|
|
5 |
#include <nanobind/stl/tuple.h> |
|
|
6 |
#include <nanobind/stl/list.h> |
|
|
7 |
#include <nanobind/ndarray.h> |
|
|
8 |
#include <nanobind/stl/shared_ptr.h> |
|
|
9 |
|
|
|
10 |
|
|
|
11 |
#include <exception> |
|
|
12 |
#include <vector> |
|
|
13 |
#include <string> |
|
|
14 |
#include <algorithm> |
|
|
15 |
|
|
|
16 |
#include "itkImage.h" |
|
|
17 |
|
|
|
18 |
#include "antscore/itkSurfaceImageCurvature.h" |
|
|
19 |
|
|
|
20 |
#include "antsImage.h" |
|
|
21 |
|
|
|
22 |
namespace nb = nanobind; |
|
|
23 |
using namespace nb::literals; |
|
|
24 |
|
|
|
25 |
AntsImage<itk::Image<float, 3>> weingartenImageCurvature( AntsImage<itk::Image<float, 3>> myimage, |
|
|
26 |
float sigma, int opt ) |
|
|
27 |
{ |
|
|
28 |
typedef itk::Image<float, 3> ImageType; |
|
|
29 |
|
|
|
30 |
typedef typename ImageType::Pointer ImagePointerType; |
|
|
31 |
enum { ImageDimension = ImageType::ImageDimension }; |
|
|
32 |
typedef itk::SurfaceImageCurvature<ImageType> ParamType; |
|
|
33 |
typename ParamType::Pointer Parameterizer = ParamType::New(); |
|
|
34 |
typename ImageType::Pointer input = myimage.ptr; |
|
|
35 |
typename ImageType::DirectionType imgdir = input->GetDirection(); |
|
|
36 |
typename ImageType::DirectionType iddir = input->GetDirection(); |
|
|
37 |
iddir.SetIdentity(); |
|
|
38 |
input->SetDirection( iddir ); |
|
|
39 |
Parameterizer->SetInputImage(input); |
|
|
40 |
Parameterizer->SetNeighborhoodRadius( 1. ); |
|
|
41 |
if( sigma <= 0.5 ) |
|
|
42 |
{ |
|
|
43 |
sigma = 1.66; |
|
|
44 |
} |
|
|
45 |
Parameterizer->SetSigma(sigma); |
|
|
46 |
Parameterizer->SetUseLabel(false); |
|
|
47 |
Parameterizer->SetUseGeodesicNeighborhood(false); |
|
|
48 |
float sign = 1.0; |
|
|
49 |
Parameterizer->SetkSign(sign); |
|
|
50 |
Parameterizer->SetThreshold(0); |
|
|
51 |
if( opt != 5 && opt != 6 ) |
|
|
52 |
{ |
|
|
53 |
Parameterizer->ComputeFrameOverDomain( 3 ); |
|
|
54 |
} |
|
|
55 |
else |
|
|
56 |
{ |
|
|
57 |
Parameterizer->ComputeFrameOverDomain( opt ); |
|
|
58 |
} |
|
|
59 |
typename ImageType::Pointer output = Parameterizer->GetFunctionImage(); |
|
|
60 |
output->SetDirection( imgdir ); |
|
|
61 |
|
|
|
62 |
AntsImage<ImageType> outImage = { output }; |
|
|
63 |
return outImage; |
|
|
64 |
|
|
|
65 |
} |
|
|
66 |
|
|
|
67 |
|
|
|
68 |
void local_weingartenImageCurvature(nb::module_ &m) |
|
|
69 |
{ |
|
|
70 |
m.def("weingartenImageCurvature", &weingartenImageCurvature); |
|
|
71 |
} |