<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Hello everyone,</div>
<div> </div>
<div>I have the following problem: after calculating the distance map (e.g. with DanielssonDistanceMapImageFilter) I am getting rid of most of the voxels (= setting 0) after calculating a so called distance ridge (kind of a skeleton). Now I want for every voxel of this distance ridge that it is a center voxel for a spherical neighborhood with the radius equal to the distance value of the voxel, and all voxels included in this sphere are set to the distance value of the voxel of the distance ridge (the center voxel of the sphere). So that means the neighborhoods can become big, e.g. radius of 10, or 20 voxels. The problem is here the performance... I implemented it somehow, but the performance nowhere near it should be.</div>
<div>e.g. going through the image with a neighborhood iterator and vor every voxel bigger than 0 creating a neighborhood with the radius with the distance value of this voxel that seems to take very long alone to create and indexing the neighborhood.</div>
<div>another approach I tried is to extract all the voxels of the distance ridge, iterate through them and calculate for every ridge voxel the region and iterate through the region doing proper calculations:</div>
<div> </div>
<div>
<div>for (int rp = 0; rp < nRidgePoints; rp++)<br/>
{<br/>
ImageType::IndexType s1Index;<br/>
const int i = ridgePointsIndex[0][rp];<br/>
const int j = ridgePointsIndex[1][rp];<br/>
const int k = ridgePointsIndex[2][rp];<br/>
const float r = ridgePointsValues[rp];</div>
<div><br/>
rSquared = (int) ((r * r) + 0.5f);<br/>
rInt = (int) r;</div>
<div> if(rInt < r) rInt++;</div>
<div> iStart = i - rInt;<br/>
if(iStart < 0) iStart = 0;<br/>
iStop = i + rInt;<br/>
if(iStop >= imageSize[0]) iStop = imageSize[0] - 1;</div>
<div> jStart = j - rInt;<br/>
if(jStart < 0) jStart = 0;<br/>
jStop = j + rInt;<br/>
if(jStop >= imageSize[1]) jStop = imageSize[1] - 1;</div>
<div> kStart = k - rInt;<br/>
if(kStart < 0) kStart = 0;<br/>
kStop = k + rInt;<br/>
if(kStop >= imageSize[2]) kStop = imageSize[2] - 1;</div>
<div> ImageType::IndexType index;<br/>
ImageType::SizeType size;</div>
<div> index[0] = iStart;<br/>
index[1] = jStart;<br/>
index[2] = kStart;</div>
<div> size[0] = iStop - iStart + 1;<br/>
size[1] = jStop - jStart + 1;<br/>
size[2] = kStop - kStart + 1;</div>
<div> ImageType::RegionType region;<br/>
region.SetIndex(index);<br/>
region.SetSize(size);</div>
<div> ImageRegionIteratorWithIndexType iteratorWithIndex (distanceRidge, region);<br/>
<br/>
for (iteratorWithIndex.GoToBegin(); !iteratorWithIndex.IsAtEnd(); iteratorWithIndex++)<br/>
{<br/>
s1Index = iteratorWithIndex.GetIndex();<br/>
r1SquaredK = (s1Index[0] - i) * (s1Index[0] - i);<br/>
r1SquaredJK = r1SquaredK + (s1Index[1] - j) * (s1Index[1] - j);</div>
<div> if(r1SquaredJK <= rSquared)<br/>
{<br/>
r1Squared = r1SquaredJK + (s1Index[2] - k) * (s1Index[2] - k);<br/>
if (r1Squared <= rSquared)<br/>
{ <br/>
s1 = iteratorWithIndex.Get();<br/>
if (rSquared > s1)<br/>
{<br/>
iteratorWithIndex.Set(rSquared); <br/>
}</div>
<div> } <br/>
}<br/>
}<br/>
<br/>
}</div>
<div> </div>
<div>so every approach I tried until now is very slow comparing to other implementations of the algorithm I want to do... would maybe spatial objects help me somehow? But I do not really understand how they work...</div>
<div>thanks for your help!</div>
<div> </div>
<div>greetings,</div>
<div>Johannes</div>
</div></div></body></html>