Skip to content

Commit

Permalink
bind gems mesh smoothing to python
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoopes committed Jan 21, 2022
1 parent ce65da0 commit 6080572
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/bindings/gems/pyKvlMesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ unsigned int KvlMeshCollection::MeshCount() const {
return meshCollection->GetNumberOfMeshes();
}

void KvlMeshCollection::Smooth(double sigma) {
kvl::AtlasMeshCollection::Pointer atlasMeshCollectionPtr = this->GetMeshCollection();
kvl::AtlasMeshSmoother::Pointer smoother = kvl::AtlasMeshSmoother::New();
smoother->SetMeshCollection(atlasMeshCollectionPtr);
smoother->SetSigma(sigma);
// note: it's very unclear that this actually updates the source mesh collection
smoother->GetSmoothedMeshCollection();
}

py::array_t<uint16_t> KvlMesh::RasterizeMesh(std::vector<size_t> size, int classNumber) {
// Some typedefs
typedef kvl::AtlasMeshAlphaDrawer::ImageType AlphaImageType;
Expand Down
2 changes: 2 additions & 0 deletions python/bindings/gems/pyKvlMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <vector>
#include "itkObject.h"
#include "kvlAtlasMeshCollection.h"
#include "kvlAtlasMeshSmoother.h"
#include "pyKvlTransform.h"

namespace py = pybind11;
Expand Down Expand Up @@ -66,6 +67,7 @@ class KvlMeshCollection {
double initialStiffness,
unsigned int numberOfClasses, unsigned int numberOfMeshes);
void Transform(const KvlTransform &transform);
void Smooth(double sigma);

// C++ use only
KvlMeshCollection();
Expand Down
1 change: 1 addition & 0 deletions python/bindings/gems/python.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ PYBIND11_MODULE(gemsbindings, m) {
.def("construct", &KvlMeshCollection::Construct, py::return_value_policy::take_ownership)
.def("read", &KvlMeshCollection::Read, py::return_value_policy::take_ownership)
.def("transform", &KvlMeshCollection::Transform, py::return_value_policy::take_ownership)
.def("smooth", &KvlMeshCollection::Smooth, py::return_value_policy::take_ownership)
.def("write", &KvlMeshCollection::Write, py::return_value_policy::take_ownership)
;
m.def("setGlobalDefaultNumberOfThreads", &setGlobalDefaultNumberOfThreads, "Sets the maximum number of threads for ITK.");
Expand Down

0 comments on commit 6080572

Please sign in to comment.