[ITK-users] setting big spherical neighborhoods to center voxel value
Richard Beare
richard.beare at gmail.com
Thu Mar 26 17:02:54 EDT 2015
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/insight-users/attachments/20150327/fc733a2e/attachment.html>
More information about the Insight-users
mailing list