[ITK] [ITK-users] setting big spherical neighborhoods to center voxel value

Richard Beare richard.beare at gmail.com
Thu Mar 26 18:47:10 EDT 2015


Here's another option - I haven't thought it through completely so could be
far from the mark, but I think it is close.

consider the following:

A - input mask
B - distance transform of mask (positive values inside the mask)
C - ridge lines in B (sort of skeleton)

You are aiming to create an image of spheres, centres on voxels in C, with
size set by the "brightness" at centre location in C.

Suppose you can create the spatially variant dilation by a sphere using the
parabolic tools I mentioned in the previous message - that gives you
another mask:

D - spatially variant dilation of C

Now invert C and take the distance transform to give E.
take a distance transform of D and add to E, then mask by D. The idea here
is that if you add two distance transforms together you end up with a flat
surface, at least in the case where the second DT is computed from peaks in
the first.

The result should be a sort of tube, of varying thickness, where the voxel
value corresponds to the tube thickness (possibly with a uniform offset).
Note that I don't think you will see sphere corresponding to the brightest
skeleton points using this approach, but the result may be useful for your
application.


Also, a couple of notes regarding the direct approach.

If you use neighbourhoods, which is the appropriate ITK structure, then
avoid visiting all voxels with the neighbourhood iterator. Use a standard
single voxel iterator to find the skeleton voxels, then move the
neighbourhood iterator to that location.

There are also some optimizations you can use if you do some checks of the
change in sphere size between neighbours. If the spheres were all
identically sized then it is feasible to construct lists of voxels that are
not in common between neighbouring spheres, and just visit those, which is
a big saving. Much trickier when the sizes aren't the same, but I'd guess
that for a given skeleton there'd be a relatively small number of
combinations of neighbouring sizes.



On Fri, Mar 27, 2015 at 8:02 AM, Richard Beare <richard.beare at gmail.com>
wrote:

> This isn't a complete solution, but might give you some ideas.
>
> 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.
>
> A queue based approach to something similar is discussed in:
> "Labelled reconstruction of binary objects: a vector propagation
> algorithm", buckley and lagerstrom
>
> On Thu, Mar 26, 2015 at 11:36 PM, Bradley Lowekamp <blowekamp at mail.nih.gov
> > wrote:
>
>> Hello,
>>
>> 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.
>>
>> 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.
>>
>> 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.
>>
>> Hope that helps,
>> Brad
>>
>> [1] http://www.itk.org/Doxygen/html/classitk_1_1NeighborhoodIterator.html
>> [2] http://itk.org/Wiki/ITK/Examples/Iterators/NeighborhoodIterator
>>
>> On Mar 26, 2015, at 5:24 AM, JohannesWeber at gmx.at wrote:
>>
>> Hello everyone,
>>
>> 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.
>> 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.
>> 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:
>>
>>  for (int rp = 0; rp < nRidgePoints; rp++)
>>     {
>>         ImageType::IndexType s1Index;
>>         const int i = ridgePointsIndex[0][rp];
>>         const int j = ridgePointsIndex[1][rp];
>>         const int k = ridgePointsIndex[2][rp];
>>         const float r = ridgePointsValues[rp];
>>
>>         rSquared = (int) ((r * r) + 0.5f);
>>         rInt = (int) r;
>>         if(rInt < r) rInt++;
>>         iStart = i - rInt;
>>         if(iStart < 0) iStart = 0;
>>         iStop = i + rInt;
>>         if(iStop >= imageSize[0]) iStop = imageSize[0] - 1;
>>         jStart = j - rInt;
>>         if(jStart < 0) jStart = 0;
>>         jStop = j + rInt;
>>         if(jStop >= imageSize[1]) jStop = imageSize[1] - 1;
>>         kStart = k - rInt;
>>         if(kStart < 0) kStart = 0;
>>         kStop = k + rInt;
>>         if(kStop >= imageSize[2]) kStop = imageSize[2] - 1;
>>         ImageType::IndexType index;
>>         ImageType::SizeType size;
>>         index[0] = iStart;
>>         index[1] = jStart;
>>         index[2] = kStart;
>>         size[0] = iStop - iStart + 1;
>>         size[1] = jStop - jStart + 1;
>>         size[2] = kStop - kStart + 1;
>>         ImageType::RegionType region;
>>         region.SetIndex(index);
>>         region.SetSize(size);
>>         ImageRegionIteratorWithIndexType iteratorWithIndex
>> (distanceRidge, region);
>>
>>         for (iteratorWithIndex.GoToBegin(); !iteratorWithIndex.IsAtEnd();
>> iteratorWithIndex++)
>>         {
>>             s1Index = iteratorWithIndex.GetIndex();
>>             r1SquaredK = (s1Index[0] - i) * (s1Index[0] - i);
>>             r1SquaredJK = r1SquaredK + (s1Index[1] - j) * (s1Index[1] -
>> j);
>>             if(r1SquaredJK <= rSquared)
>>             {
>>                 r1Squared = r1SquaredJK + (s1Index[2] - k) * (s1Index[2]
>> - k);
>>                 if (r1Squared <= rSquared)
>>                 {
>>                     s1 = iteratorWithIndex.Get();
>>                     if (rSquared > s1)
>>                     {
>>                         iteratorWithIndex.Set(rSquared);
>>
>>                     }
>>                 }
>>             }
>>         }
>>
>>     }
>>
>> 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...
>> thanks for your help!
>>
>> greetings,
>> Johannes
>>  _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/insight-users
>>
>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/insight-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150327/4b0bae4c/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list