[Insight-users] read vtkImageData

David Doria daviddoria at gmail.com
Thu Nov 14 16:32:33 EST 2013


On Thu, Nov 14, 2013 at 4:07 PM, Massinissa Bandou
<Massinissa.Bandou at usherbrooke.ca> wrote:
> Hi David,
>
> Thanks for reply.
> Can you tell me what does it do this part of code in:
> http://www.itk.org/Wiki/ITK/Examples/IO/ImportImageFilter ???
>
>   for(unsigned int z=0; z < size[2]; z++)
>     {
>     const double dz = static_cast<double>( z ) -
> static_cast<double>(size[2])/2.0;
>     for(unsigned int y=0; y < size[1]; y++)
>       {
>       const double dy = static_cast<double>( y ) -
> static_cast<double>(size[1])/2.0;
>       for(unsigned int x=0; x < size[0]; x++)
>         {
>         const double dx = static_cast<double>( x ) -
> static_cast<double>(size[0])/2.0;
>         const double d2 = dx*dx + dy*dy + dz*dz;
>         *it++ = ( d2 < radius2 ) ? 255 : 0;
>         }
>       }
>     }


It just iterates over the image filling in a sphere (all pixels less
than 'radius2') with white pixels.


David


More information about the Insight-users mailing list