[Insight-users] How to convert 3d image into 1D vector array......

Víctor Rodrigo vrcordoba at ymail.com
Wed May 27 14:39:26 EDT 2009


Hello.

I don't know if is the best option, but you can do something like this:


ImageType::SizeType size=image->GetLargestPossibleRegion().GetSize();
ImageType::IndexType index;
int i=0;
int numVox=size[0]*size[1]*size[2];
PixelType* img=new PixelType[numVox];
for(index[2]=0;index[2]<size[2];index[2]++) {
     for(index[1]=0;index[1]<size[1];index[1]++) {
           for(index[0]=0;index[0]<size[0];index[0]++) {
                img[i++]=image->GetPixel(index);
           }
      }
}


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090527/5ac20ae2/attachment.htm>


More information about the Insight-users mailing list