[Insight-users] 3D volume image neighborhood iterator?

Sergio Vera sergio.vera at alma3d.com
Fri Mar 4 04:17:30 EST 2011


Then you may try something like this (I haven't compiled it properly, may
contain errors)

typedef itk::ConstNeighBorhoodIterator<SOME_ITK_IMG_TYPE> IteratorType;
IteratorType::RadiusType radius;
radius.Fill(1); // this is equivalent to 3x3x3 neigborhood
IteratorType nit( radius, my_image, my_image->GetLargestPossibleRegion());
for(nit.GotoBegin(); !nit.IsAtEnd(); ++it) { // this first loop moves the
iterator to all the voxels
  for (size_t i = 0; i < nit.Size(); ++i) { // this loop moves inside the
3x3x3 neighborhood
    SOME_ITK_IMG_TYPE::PixelType = nit.GetPixel( i );
    // do something with the voxel
  }
}

HTH

On Fri, Mar 4, 2011 at 10:06 AM, Wang Zhimin <zwang at i2r.a-star.edu.sg>wrote:

> Hi, Sergio,
>
> That's my bottom line to achieve my goal. Currently I am looking for
> options that can do it in a better way. Else I will just process 3 slices in
> 2D way at each iteration to visit all the 26 neighborhood voxels.
>
> Regards,
> Zhimin
>
>
> On 04-Mar-2011, at 5:02 PM, Sergio Vera wrote:
>
> Hi Zhimin
>
> Yes, indeed you can use a radius of 1x1x1 to obtain a 3x3x3 region and hace
> access to the full 26 Neighborthood.
>
> However, if you are interested in processing the 3x3x3 region slice by
> slice (I understood this from your first email) you should use 1x1x0 radius,
> process the slice, and then move the iterator upwards or downwards to the
> next slice: even if the neighborhood region of the iterator is 2D (3x3x0)
> the iterator itself can move freely in 3D within the image.
>
> Regards
>
> On Fri, Mar 4, 2011 at 9:57 AM, Wang Zhimin <zwang at i2r.a-star.edu.sg>wrote:
>
>> Hi, Sergio
>>
>> Thank you very much.
>>
>> My image is volume image (3D), not planar image (2D). Actually, I want
>> something like radius of 1x1x1, neighbor hood voxels size of 26 (3x3x3 - 1).
>>
>> Do you know how to do that?
>>
>> Regards,
>> Zhimin
>>
>>
>> On 04-Mar-2011, at 4:48 PM, Sergio Vera wrote:
>>
>> Hello Zhimin
>>
>> Try itk::NeighborhoodIterator<http://www.itk.org/Doxygen320/html/classitk_1_1NeighborhoodIterator.html>
>>
>> <http://www.itk.org/Doxygen320/html/classitk_1_1NeighborhoodIterator.html>(or
>> it's const variant). You can initialize it with your image, your desired
>> region and setting a radius of 1x1x0 with SetRadius member function. to
>> define a neighborhood of 3x3x0 in the z axis plane. Then you can put the
>> iterator at each slice with the SetLocation function.
>>
>> Once your iterator is centered at each voxel, you can actually read it's
>> neighborhood using the GetPixel(i) method. With your neighborhood of 3x3x0,
>> i must be between 0 and 9.
>>
>> HTH
>>
>> Sergio
>>
>> On Fri, Mar 4, 2011 at 8:43 AM, Wang Zhimin <zwang at i2r.a-star.edu.sg>wrote:
>>
>>> Hi, all,
>>>
>>> Thank you all in advance for reading this question.
>>>
>>> I am looking for a way to read all the neighborhood voxels for a 3x3x3
>>> neighboring window for a 3D volume image.
>>>
>>> I find all the online resource, itksoftwareguide, itk example, and
>>> mailing list archive, all failed.
>>>
>>> Can any one give me some example codes to do this?
>>>
>>> Some notes:
>>> 1) I think a ImageSliceIteratorWithIndex may work, but I cannot figure
>>> out HOW through the example.
>>> 2) I want to use 2D neighborhood iterator for each slice, but I need to
>>> coordinate at least 3 slices (previous, center, and next) with correct
>>> index, and it is too complicated.
>>> 3) I also want to use
>>> itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator to get the
>>> non-boundary region, I don't have any boundary condition, so what I need is
>>> just to focus on the non-boundary region.
>>>
>>> Once again, thank you.
>>>
>>> Regards,
>>> Zhimin
>>>
>>> Institute for Infocomm Research disclaimer:  "This email is confidential
>>> and may be privileged. If you are not the intended recipient, please delete
>>> it and notify us immediately. Please do not copy or use it for any purpose,
>>> or disclose its contents to any other person. Thank you."
>>> _____________________________________
>>> 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.html
>>>
>>> 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://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>>
>>
>> --
>> Sergio Vera
>>
>>  Alma IT Systems
>>  C/ Vilana, 4B, 4º 1ª
>>  08022 Barcelona
>>  T. (+34) 932 380 592
>>  www.alma3d.com
>>
>>
>>  Institute for Infocomm Research disclaimer: "This email is confidential
>> and may be privileged. If you are not the intended recipient, please delete
>> it and notify us immediately. Please do not copy or use it for any purpose,
>> or disclose its contents to any other person. Thank you."
>>
>
>
>
> --
> Sergio Vera
>
>  Alma IT Systems
>  C/ Vilana, 4B, 4º 1ª
>  08022 Barcelona
>  T. (+34) 932 380 592
>  www.alma3d.com
>
>
>  Institute for Infocomm Research disclaimer: "This email is confidential
> and may be privileged. If you are not the intended recipient, please delete
> it and notify us immediately. Please do not copy or use it for any purpose,
> or disclose its contents to any other person. Thank you."
>



-- 
Sergio Vera

 Alma IT Systems
 C/ Vilana, 4B, 4º 1ª
 08022 Barcelona
 T. (+34) 932 380 592
 www.alma3d.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110304/47e7e967/attachment.htm>


More information about the Insight-users mailing list