<div dir="ltr">This isn't a complete solution, but might give you some ideas.<div><br></div><div>The part about using the skeleton points, which are distance transform voxels, as the source for the radius, can be implemented using spatially variant morphology. I have a short publication about doing this efficiently with parabolic functions. However this doesn't propagate the voxel value, only producing a mask. I have thought about combining with label dilation, to propagate a label value, but haven't done it yet.</div><div><br></div><div>A queue based approach to something similar is discussed in:</div><div>"Labelled reconstruction of binary objects: a vector propagation algorithm", buckley and lagerstrom </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 26, 2015 at 11:36 PM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hello,<div><br></div><div>If you have a 3D image and you are visiting a neighborhood of size 20^3, you are doing 8000 visits per pixel there is no way to make this efficient. You have a big O algorithm problem.</div><div><br></div><div>The Neighborhood iterator would be a the more ITK way of doing what you are trying to do [1] [2]. But that's is not the order of efficiency improvement you need.</div><div><br></div><div>You need to revise your algorithm so you only visit each pixel once. Perhaps with region growing and queues, or auxiliary images to keep track of the current distance or other data.</div><div><br></div><div>Hope that helps,</div><div>Brad</div><div><br></div><div>[1] <a href="http://www.itk.org/Doxygen/html/classitk_1_1NeighborhoodIterator.html" target="_blank">http://www.itk.org/Doxygen/html/classitk_1_1NeighborhoodIterator.html</a></div><div>[2] <a href="http://itk.org/Wiki/ITK/Examples/Iterators/NeighborhoodIterator" target="_blank">http://itk.org/Wiki/ITK/Examples/Iterators/NeighborhoodIterator</a></div><div><br><div><div>On Mar 26, 2015, at 5:24 AM, <a href="mailto:JohannesWeber@gmx.at" target="_blank">JohannesWeber@gmx.at</a> wrote:</div><br><blockquote type="cite">
<div><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></div>
_____________________________________<br>Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br><br>Please keep messages on-topic and check the ITK FAQ at:<br><a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br></blockquote></div><br></div></div><br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>