11 const char VolumeSkeletonizer::THINNING_CLASS_SURFACE_PRESERVATION = 4;
12 const char VolumeSkeletonizer::THINNING_CLASS_CURVE_PRESERVATION_2D = 3;
13 const char VolumeSkeletonizer::THINNING_CLASS_CURVE_PRESERVATION = 2;
14 const char VolumeSkeletonizer::THINNING_CLASS_POINT_PRESERVATION = 1;
15 const char VolumeSkeletonizer::THINNING_CLASS_TOPOLOGY_PRESERVATION = 0;
16 const char VolumeSkeletonizer::PRUNING_CLASS_PRUNE_SURFACES = 5;
17 const char VolumeSkeletonizer::PRUNING_CLASS_PRUNE_CURVES = 6;
18 const char VolumeSkeletonizer::PRUNING_CLASS_PRUNE_POINTS = 7;
20 VolumeSkeletonizer::VolumeSkeletonizer(
int pointRadius,
int curveRadius,
int surfaceRadius,
int skeletonDirectionRadius) {
55 if ( u==v || abs(u[0]-v[0])>1 || abs(u[1]-v[1])>1 || abs(u[2]-v[2])>1) {
65 int faceNeighbors[3][3][3] = { {{1,0,0}, {1,0,1}, {0,0,1}},
66 {{1,0,0}, {1,1,0}, {0,1,0}},
67 {{0,1,0}, {0,1,1}, {0,0,1}} };
71 for (
int z = 0; z < skeleton->
getSizeZ(); z++) {
76 for (
int n = 0; n < 3; n++) {
78 for (
int m = 0; m < 3; m++) {
79 indices[m+1] = skeleton->
getIndex(
x+faceNeighbors[n][m][0],
y+faceNeighbors[n][m][1], z+faceNeighbors[n][m][2]);
80 faceFound = faceFound && (skeleton->
getDataAt(indices[m+1]) > 0);
83 for (
int m = 0; m < 4; m++) {
97 list< Vec3<int> > skel_indices;
99 for (
int k=0; k < skeleton->
getSizeZ(); k++) {
100 for (
int j=0; j < skeleton->
getSizeY(); j++) {
101 for (
int i=0; i < skeleton->
getSizeX(); i++) {
102 if (skeleton->
getDataAt(i,j,k) > valueThreshold) {
104 skel_indices.push_front(voxel_indices);
110 vector< Vec3<int> > segment;
111 list< Vec3<int> >::iterator itr;
119 while (skel_indices.size() > 0) {
121 segment.push_back(skel_indices.front());
122 skel_indices.pop_front();
125 for (
unsigned int seg_ix=0; seg_ix < segment.size(); seg_ix++) {
126 for (itr = skel_indices.begin(); itr != skel_indices.end(); itr++) {
129 segment.push_back(*itr);
130 skel_indices.erase(itr);
137 if (segment.size() <
static_cast<unsigned int>(minNumVoxels)) {
138 for (
unsigned int ix=0; ix<segment.size(); ix++) {
139 skeleton->
setDataAt(segment[ix][0], segment[ix][1], segment[ix][2],0.0f);
158 VoxelOr(preservedVol, surfaceVol);
161 VoxelOr(preservedVol, curveVol);
202 return GetJuThinning(sourceVolume, preserve, threshold, thinningClass);
215 switch(thinningClass) {
226 thinnedVolume->
skeleton((
float)threshold, preserve, preserve);
228 return thinnedVolume;
239 if(sourceVolume2 != NULL) {
240 for(
int x = 0;
x < sourceAndDestVolume1->
getSizeX();
x++) {
241 for(
int y = 0;
y < sourceAndDestVolume1->
getSizeY();
y++) {
242 for(
int z = 0; z < sourceAndDestVolume1->
getSizeZ(); z++) {
void set_value(const vector< Type2 > &v)
Set new values using a std::vector object.
static bool Are26Neighbors(Vec3< int > u, Vec3< int > v)
static const char THINNING_CLASS_CURVE_PRESERVATION
static void MarkSurfaces(Volume *skeleton)
static Volume * GetJuTopologySkeleton(Volume *sourceVolume, Volume *preserve, double threshold)
static void PruneSurfaces(Volume *sourceVolume, int pruneLength)
static Volume * GetJuThinning(Volume *sourceVolume, Volume *preserve, double threshold, char thinningClass)
static void VoxelOr(Volume *sourceAndDestVolume1, Volume *sourceVolume2)
int skeletonDirectionRadius
static Volume * GetJuCurveSkeleton(Volume *sourceVolume, Volume *preserve, double threshold, bool is3D)
static void CleanUpSkeleton(Volume *skeleton, int minNumVoxels=4, float valueThreshold=0.5)
static Volume * PerformPureJuSkeletonization(Volume *imageVol, string outputPath, double threshold, int minCurveWidth, int minSurfaceWidth)
static const char THINNING_CLASS_CURVE_PRESERVATION_2D
static Volume * GetJuSurfaceSkeleton(Volume *sourceVolume, Volume *preserve, double threshold)
static const char THINNING_CLASS_SURFACE_PRESERVATION
static const char THINNING_CLASS_TOPOLOGY_PRESERVATION
static void PruneCurves(Volume *sourceVolume, int pruneLength)
void skeleton(float thr, int off)
int getIndex(int x, int y, int z)
void pad(int padBy, double padValue)
void curveSkeleton(Volume *grayvol, float lowthr, float highthr, Volume *svol)
insert them back into priority queue
void surfaceSkeletonPres(float thr, Volume *preserve)
for ( int m = 0 ; m < 6 ; m ++ )
void curveSkeleton2D(float thr, Volume *svol)
double getDataAt(int x, int y, int z)
void setDataAt(int x, int y, int z, double d)
const int MAX_GAUSSIAN_FILTER_RADIUS