EMAN2
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
wustl_mm::GraySkeletonCPP::VolumeSkeletonizer Class Reference

#include <skeletonizer.h>

Public Member Functions

 VolumeSkeletonizer (int pointRadius, int curveRadius, int surfaceRadius, int skeletonDirectionRadius=DEFAULT_SKELETON_DIRECTION_RADIUS)
 
 ~VolumeSkeletonizer ()
 

Static Public Member Functions

static VolumePerformPureJuSkeletonization (Volume *imageVol, string outputPath, double threshold, int minCurveWidth, int minSurfaceWidth)
 
static void CleanUpSkeleton (Volume *skeleton, int minNumVoxels=4, float valueThreshold=0.5)
 
static void MarkSurfaces (Volume *skeleton)
 

Static Private Member Functions

static bool Are26Neighbors (Vec3< int > u, Vec3< int > v)
 
static VolumeGetJuSurfaceSkeleton (Volume *sourceVolume, Volume *preserve, double threshold)
 
static VolumeGetJuCurveSkeleton (Volume *sourceVolume, Volume *preserve, double threshold, bool is3D)
 
static VolumeGetJuTopologySkeleton (Volume *sourceVolume, Volume *preserve, double threshold)
 
static void PruneCurves (Volume *sourceVolume, int pruneLength)
 
static void PruneSurfaces (Volume *sourceVolume, int pruneLength)
 
static void VoxelOr (Volume *sourceAndDestVolume1, Volume *sourceVolume2)
 
static VolumeGetJuThinning (Volume *sourceVolume, Volume *preserve, double threshold, char thinningClass)
 

Private Attributes

int pointRadius
 
int curveRadius
 
int surfaceRadius
 
int skeletonDirectionRadius
 

Static Private Attributes

static const char THINNING_CLASS_SURFACE_PRESERVATION = 4
 
static const char THINNING_CLASS_CURVE_PRESERVATION_2D = 3
 
static const char THINNING_CLASS_CURVE_PRESERVATION = 2
 
static const char THINNING_CLASS_POINT_PRESERVATION = 1
 
static const char THINNING_CLASS_TOPOLOGY_PRESERVATION = 0
 
static const char PRUNING_CLASS_PRUNE_SURFACES = 5
 
static const char PRUNING_CLASS_PRUNE_CURVES = 6
 
static const char PRUNING_CLASS_PRUNE_POINTS = 7
 

Detailed Description

Definition at line 17 of file skeletonizer.h.

Constructor & Destructor Documentation

◆ VolumeSkeletonizer()

VolumeSkeletonizer::VolumeSkeletonizer ( int  pointRadius,
int  curveRadius,
int  surfaceRadius,
int  skeletonDirectionRadius = DEFAULT_SKELETON_DIRECTION_RADIUS 
)

Definition at line 20 of file skeletonizer.cpp.

20 {
21// math = new MathLib();
22// surfaceNormalFinder = new NormalFinder();
27
28// gaussianFilterPointRadius.radius = pointRadius;
29// math->GetBinomialDistribution(gaussianFilterPointRadius);
30//
31// gaussianFilterCurveRadius.radius = curveRadius;
32// math->GetBinomialDistribution(gaussianFilterCurveRadius);
33//
34// gaussianFilterSurfaceRadius.radius = surfaceRadius;
35// math->GetBinomialDistribution(gaussianFilterSurfaceRadius);
36//
37// gaussianFilterMaxRadius.radius = MAX_GAUSSIAN_FILTER_RADIUS;
38// math->GetBinomialDistribution(gaussianFilterMaxRadius);
39//
40// uniformFilterSkeletonDirectionRadius.radius = skeletonDirectionRadius;
41// math->GetUniformDistribution(uniformFilterSkeletonDirectionRadius);
42 }

References curveRadius, pointRadius, skeletonDirectionRadius, and surfaceRadius.

◆ ~VolumeSkeletonizer()

VolumeSkeletonizer::~VolumeSkeletonizer ( )

Definition at line 44 of file skeletonizer.cpp.

44 {
45 //delete math;
46 //delete surfaceNormalFinder;
47 }

Member Function Documentation

◆ Are26Neighbors()

bool VolumeSkeletonizer::Are26Neighbors ( Vec3< int >  u,
Vec3< int >  v 
)
staticprivate

Definition at line 54 of file skeletonizer.cpp.

54 {
55 if ( u==v || abs(u[0]-v[0])>1 || abs(u[1]-v[1])>1 || abs(u[2]-v[2])>1) {
56 return false;
57 } else {
58 return true;
59 }
60 }

Referenced by CleanUpSkeleton().

◆ CleanUpSkeleton()

void VolumeSkeletonizer::CleanUpSkeleton ( Volume skeleton,
int  minNumVoxels = 4,
float  valueThreshold = 0.5 
)
static

Definition at line 94 of file skeletonizer.cpp.

94 {
95
96 //Get the indices of voxels that are above the threshold, i.e. part of the skeleton
97 list< Vec3<int> > skel_indices;
98 Vec3<int> voxel_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) {
103 voxel_indices.set_value(i,j,k);
104 skel_indices.push_front(voxel_indices);
105 }
106 }
107 }
108 }
109
110 vector< Vec3<int> > segment; //the coordinates for a set of connected skeleton voxels
111 list< Vec3<int> >::iterator itr;
112
113 /*
114 1. Group the connected voxels together
115 2. Check the number of voxels in that group
116 3. If below the minimum number of voxels, remove them from the skeleton
117 4. Repeat until all the voxels in the skeleton have been grouped (possibly alone if not connected)
118 */
119 while (skel_indices.size() > 0) {
120 segment.clear();
121 segment.push_back(skel_indices.front());
122 skel_indices.pop_front();
123 // group connected voxels -- each member of segment neighbors at least one other member of segment
124 //For each voxel in segment, we test if each voxel in skel_indices is a neighbor
125 for (unsigned int seg_ix=0; seg_ix < segment.size(); seg_ix++) {
126 for (itr = skel_indices.begin(); itr != skel_indices.end(); itr++) {
127
128 if (Are26Neighbors(segment[seg_ix], *itr)) {
129 segment.push_back(*itr);
130 skel_indices.erase(itr);
131 }
132 }
133 } //Now, a segment is complete
134
135
136 //If the region of connected voxels is too small, remove them from the map
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);
140 }
141 }
142
143 }
144 }
void set_value(const vector< Type2 > &v)
Set new values using a std::vector object.
Definition: vec3.h:408
static bool Are26Neighbors(Vec3< int > u, Vec3< int > v)
double getDataAt(int x, int y, int z)
Definition: volume.cpp:60
void setDataAt(int x, int y, int z, double d)
Definition: volume.cpp:52

References Are26Neighbors(), wustl_mm::SkeletonMaker::Volume::getDataAt(), wustl_mm::SkeletonMaker::Volume::getSizeX(), wustl_mm::SkeletonMaker::Volume::getSizeY(), wustl_mm::SkeletonMaker::Volume::getSizeZ(), EMAN::Vec3< Type >::set_value(), and wustl_mm::SkeletonMaker::Volume::setDataAt().

◆ GetJuCurveSkeleton()

Volume * VolumeSkeletonizer::GetJuCurveSkeleton ( Volume sourceVolume,
Volume preserve,
double  threshold,
bool  is3D 
)
staticprivate

Definition at line 200 of file skeletonizer.cpp.

200 {
202 return GetJuThinning(sourceVolume, preserve, threshold, thinningClass);
203 }
static Volume * GetJuThinning(Volume *sourceVolume, Volume *preserve, double threshold, char thinningClass)

References GetJuThinning(), THINNING_CLASS_CURVE_PRESERVATION, and THINNING_CLASS_CURVE_PRESERVATION_2D.

Referenced by PerformPureJuSkeletonization().

◆ GetJuSurfaceSkeleton()

Volume * VolumeSkeletonizer::GetJuSurfaceSkeleton ( Volume sourceVolume,
Volume preserve,
double  threshold 
)
staticprivate

Definition at line 205 of file skeletonizer.cpp.

205 {
206 return GetJuThinning(sourceVolume, preserve, threshold, THINNING_CLASS_SURFACE_PRESERVATION);
207 }

References GetJuThinning(), and THINNING_CLASS_SURFACE_PRESERVATION.

Referenced by PerformPureJuSkeletonization().

◆ GetJuThinning()

Volume * VolumeSkeletonizer::GetJuThinning ( Volume sourceVolume,
Volume preserve,
double  threshold,
char  thinningClass 
)
staticprivate

Definition at line 213 of file skeletonizer.cpp.

213 {
214 Volume * thinnedVolume = new Volume(sourceVolume->getSizeX(), sourceVolume->getSizeY(), sourceVolume->getSizeZ(), 0, 0, 0, sourceVolume);
215 switch(thinningClass) {
217 thinnedVolume->surfaceSkeletonPres((float)threshold, preserve);
218 break;
220 thinnedVolume->curveSkeleton((float)threshold, preserve);
221 break;
223 thinnedVolume->curveSkeleton2D((float)threshold, preserve);
224 break;
226 thinnedVolume->skeleton((float)threshold, preserve, preserve);
227 }
228 return thinnedVolume;
229 }
void skeleton(float thr, int off)
Definition: volume.cpp:5089
void curveSkeleton(Volume *grayvol, float lowthr, float highthr, Volume *svol)
insert them back into priority queue
Definition: volume.cpp:3812
void surfaceSkeletonPres(float thr, Volume *preserve)
for ( int m = 0 ; m < 6 ; m ++ )
Definition: volume.cpp:8672
void curveSkeleton2D(float thr, Volume *svol)
Definition: volume.cpp:4678

References wustl_mm::SkeletonMaker::Volume::curveSkeleton(), wustl_mm::SkeletonMaker::Volume::curveSkeleton2D(), wustl_mm::SkeletonMaker::Volume::getSizeX(), wustl_mm::SkeletonMaker::Volume::getSizeY(), wustl_mm::SkeletonMaker::Volume::getSizeZ(), wustl_mm::SkeletonMaker::Volume::skeleton(), wustl_mm::SkeletonMaker::Volume::surfaceSkeletonPres(), THINNING_CLASS_CURVE_PRESERVATION, THINNING_CLASS_CURVE_PRESERVATION_2D, THINNING_CLASS_SURFACE_PRESERVATION, and THINNING_CLASS_TOPOLOGY_PRESERVATION.

Referenced by GetJuCurveSkeleton(), GetJuSurfaceSkeleton(), and GetJuTopologySkeleton().

◆ GetJuTopologySkeleton()

Volume * VolumeSkeletonizer::GetJuTopologySkeleton ( Volume sourceVolume,
Volume preserve,
double  threshold 
)
staticprivate

Definition at line 209 of file skeletonizer.cpp.

209 {
210 return GetJuThinning(sourceVolume, preserve, threshold, THINNING_CLASS_TOPOLOGY_PRESERVATION);
211 }

References GetJuThinning(), and THINNING_CLASS_TOPOLOGY_PRESERVATION.

Referenced by PerformPureJuSkeletonization().

◆ MarkSurfaces()

void VolumeSkeletonizer::MarkSurfaces ( Volume skeleton)
static

Definition at line 63 of file skeletonizer.cpp.

63 {
64
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}} };
68 int indices[4];
69 bool faceFound;
70
71 for (int z = 0; z < skeleton->getSizeZ(); z++) {
72 for (int y = 0; y < skeleton->getSizeY(); y++) {
73 for (int x = 0; x < skeleton->getSizeX(); x++) {
74
75 indices[0] = skeleton->getIndex(x,y,z);
76 for (int n = 0; n < 3; n++) {
77 faceFound = true;
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);
81 }
82 if (faceFound) {
83 for (int m = 0; m < 4; m++) {
84 skeleton->setDataAt(indices[m], SURFACE_VAL);
85 }
86 }
87 }
88
89 }
90 }
91 }
92 }
int getIndex(int x, int y, int z)
Definition: volume.cpp:48
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517
const float SURFACE_VAL

References wustl_mm::SkeletonMaker::Volume::getDataAt(), wustl_mm::SkeletonMaker::Volume::getIndex(), wustl_mm::SkeletonMaker::Volume::getSizeX(), wustl_mm::SkeletonMaker::Volume::getSizeY(), wustl_mm::SkeletonMaker::Volume::getSizeZ(), wustl_mm::SkeletonMaker::Volume::setDataAt(), SURFACE_VAL, x, and y.

◆ PerformPureJuSkeletonization()

Volume * VolumeSkeletonizer::PerformPureJuSkeletonization ( Volume imageVol,
string  outputPath,
double  threshold,
int  minCurveWidth,
int  minSurfaceWidth 
)
static

Definition at line 148 of file skeletonizer.cpp.

148 {
149 imageVol->pad(MAX_GAUSSIAN_FILTER_RADIUS, 0);
150 Volume * preservedVol = new Volume(imageVol->getSizeX(), imageVol->getSizeY(), imageVol->getSizeZ());
151 Volume * surfaceVol;
152 Volume * curveVol;
153 Volume * topologyVol;
154 //printf("\t\t\tUSING THRESHOLD : %f\n", threshold);
155 // Skeletonizing while preserving surface features curve features and topology
156 surfaceVol = GetJuSurfaceSkeleton(imageVol, preservedVol, threshold);
157 PruneSurfaces(surfaceVol, minSurfaceWidth);
158 VoxelOr(preservedVol, surfaceVol);
159 curveVol = VolumeSkeletonizer::GetJuCurveSkeleton(imageVol, preservedVol, threshold, true);
160 VolumeSkeletonizer::PruneCurves(curveVol, minCurveWidth);
161 VoxelOr(preservedVol, curveVol);
162
163 topologyVol = VolumeSkeletonizer::GetJuTopologySkeleton(imageVol, preservedVol, threshold);
164
165 //Code below by Ross as a test -- to replace GetJuTopologySkeleton return value
166// int curveVolMax = curveVol->getVolumeData()->GetMaxIndex();
167// int surfaceVolMax = curveVol->getVolumeData()->GetMaxIndex();
168// int maximum = curveVolMax <= surfaceVolMax? curveVolMax : surfaceVolMax;
169// if (curveVolMax != surfaceVolMax)
170// cout << "Curve Skeleton: " << curveVolMax << '\n' << "Surface Skeleton" << surfaceVolMax << endl;
171// topologyVol = new Volume(curveVol->getSizeX(), curveVol->getSizeY(), curveVol->getSizeZ());
172// float val, cval, sval;
173// for (int i = 0; i < maximum; i++)
174// {
175// cval = float(curveVol->getDataAt(i));
176// sval = float(surfaceVol->getDataAt(i));
177// if (cval && sval)
178// val = 100; //Something went wrong!
179// else if (cval)
180// val = 1;
181// else if (sval)
182// val = -1;
183// else
184// val = 0;
185// topologyVol->setDataAt(i, val);
186// }
187
188
189
190
191
192 imageVol->pad(-MAX_GAUSSIAN_FILTER_RADIUS, 0);
193 topologyVol->pad(-MAX_GAUSSIAN_FILTER_RADIUS, 0);
194 delete preservedVol;
195 delete surfaceVol;
196 delete curveVol;
197 return topologyVol;
198 }
static Volume * GetJuTopologySkeleton(Volume *sourceVolume, Volume *preserve, double threshold)
static void PruneSurfaces(Volume *sourceVolume, int pruneLength)
static void VoxelOr(Volume *sourceAndDestVolume1, Volume *sourceVolume2)
static Volume * GetJuCurveSkeleton(Volume *sourceVolume, Volume *preserve, double threshold, bool is3D)
static Volume * GetJuSurfaceSkeleton(Volume *sourceVolume, Volume *preserve, double threshold)
static void PruneCurves(Volume *sourceVolume, int pruneLength)
void pad(int padBy, double padValue)
Definition: volume.cpp:273
const int MAX_GAUSSIAN_FILTER_RADIUS
Definition: skeletonizer.h:11

References GetJuCurveSkeleton(), GetJuSurfaceSkeleton(), GetJuTopologySkeleton(), wustl_mm::SkeletonMaker::Volume::getSizeX(), wustl_mm::SkeletonMaker::Volume::getSizeY(), wustl_mm::SkeletonMaker::Volume::getSizeZ(), MAX_GAUSSIAN_FILTER_RADIUS, wustl_mm::SkeletonMaker::Volume::pad(), PruneCurves(), PruneSurfaces(), and VoxelOr().

◆ PruneCurves()

void VolumeSkeletonizer::PruneCurves ( Volume sourceVolume,
int  pruneLength 
)
staticprivate

Definition at line 231 of file skeletonizer.cpp.

231 {
232 sourceVolume->erodeHelix(pruneLength);
233 }

References wustl_mm::SkeletonMaker::Volume::erodeHelix().

Referenced by PerformPureJuSkeletonization().

◆ PruneSurfaces()

void VolumeSkeletonizer::PruneSurfaces ( Volume sourceVolume,
int  pruneLength 
)
staticprivate

Definition at line 234 of file skeletonizer.cpp.

234 {
235 sourceVolume->erodeSheet(pruneLength);
236 }

References wustl_mm::SkeletonMaker::Volume::erodeSheet().

Referenced by PerformPureJuSkeletonization().

◆ VoxelOr()

void VolumeSkeletonizer::VoxelOr ( Volume sourceAndDestVolume1,
Volume sourceVolume2 
)
staticprivate

Definition at line 238 of file skeletonizer.cpp.

238 {
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++) {
243 sourceAndDestVolume1->setDataAt(x, y, z, max(sourceAndDestVolume1->getDataAt(x, y, z), sourceVolume2->getDataAt(x, y, z)));
244 }
245 }
246 }
247 }
248 }

References wustl_mm::SkeletonMaker::Volume::getDataAt(), wustl_mm::SkeletonMaker::Volume::getSizeX(), wustl_mm::SkeletonMaker::Volume::getSizeY(), wustl_mm::SkeletonMaker::Volume::getSizeZ(), wustl_mm::SkeletonMaker::Volume::setDataAt(), x, and y.

Referenced by PerformPureJuSkeletonization().

Member Data Documentation

◆ curveRadius

int wustl_mm::GraySkeletonCPP::VolumeSkeletonizer::curveRadius
private

Definition at line 54 of file skeletonizer.h.

Referenced by VolumeSkeletonizer().

◆ pointRadius

int wustl_mm::GraySkeletonCPP::VolumeSkeletonizer::pointRadius
private

Definition at line 53 of file skeletonizer.h.

Referenced by VolumeSkeletonizer().

◆ PRUNING_CLASS_PRUNE_CURVES

const char VolumeSkeletonizer::PRUNING_CLASS_PRUNE_CURVES = 6
staticprivate

Definition at line 43 of file skeletonizer.h.

◆ PRUNING_CLASS_PRUNE_POINTS

const char VolumeSkeletonizer::PRUNING_CLASS_PRUNE_POINTS = 7
staticprivate

Definition at line 44 of file skeletonizer.h.

◆ PRUNING_CLASS_PRUNE_SURFACES

const char VolumeSkeletonizer::PRUNING_CLASS_PRUNE_SURFACES = 5
staticprivate

Definition at line 42 of file skeletonizer.h.

◆ skeletonDirectionRadius

int wustl_mm::GraySkeletonCPP::VolumeSkeletonizer::skeletonDirectionRadius
private

Definition at line 56 of file skeletonizer.h.

Referenced by VolumeSkeletonizer().

◆ surfaceRadius

int wustl_mm::GraySkeletonCPP::VolumeSkeletonizer::surfaceRadius
private

Definition at line 55 of file skeletonizer.h.

Referenced by VolumeSkeletonizer().

◆ THINNING_CLASS_CURVE_PRESERVATION

const char VolumeSkeletonizer::THINNING_CLASS_CURVE_PRESERVATION = 2
staticprivate

Definition at line 39 of file skeletonizer.h.

Referenced by GetJuCurveSkeleton(), and GetJuThinning().

◆ THINNING_CLASS_CURVE_PRESERVATION_2D

const char VolumeSkeletonizer::THINNING_CLASS_CURVE_PRESERVATION_2D = 3
staticprivate

Definition at line 38 of file skeletonizer.h.

Referenced by GetJuCurveSkeleton(), and GetJuThinning().

◆ THINNING_CLASS_POINT_PRESERVATION

const char VolumeSkeletonizer::THINNING_CLASS_POINT_PRESERVATION = 1
staticprivate

Definition at line 40 of file skeletonizer.h.

◆ THINNING_CLASS_SURFACE_PRESERVATION

const char VolumeSkeletonizer::THINNING_CLASS_SURFACE_PRESERVATION = 4
staticprivate

Definition at line 37 of file skeletonizer.h.

Referenced by GetJuSurfaceSkeleton(), and GetJuThinning().

◆ THINNING_CLASS_TOPOLOGY_PRESERVATION

const char VolumeSkeletonizer::THINNING_CLASS_TOPOLOGY_PRESERVATION = 0
staticprivate

Definition at line 41 of file skeletonizer.h.

Referenced by GetJuThinning(), and GetJuTopologySkeleton().


The documentation for this class was generated from the following files: