[Insight-users] creating matrix of itkImage
michiel mentink
michael.mentink at st-hughs.ox.ac.uk
Thu Apr 1 10:32:06 EDT 2010
Hi all,
I'm trying to create an array of itkImages.
This is what i got so far:
int numLabels = 2;
ImageType::Pointer* imageMatrix = new ImageType::Pointer[numLabels];
for( unsigned int i=0;i<2;i++){
imageMatrix[i]= ImageType::New();
imageMatrix[i]->SetSpacing(sp);
imageMatrix[i]->SetOrigin(origin);
imageMatrix[i]->SetDirection(direction);
imageMatrix[i]->SetLargestPossibleRegion(image->GetLargestPossibleRegion());
}
ImageType::SizeType sizeOfImage2 =
imageMatrix[0]->GetLargestPossibleRegion().GetSize();
std::cout << "Size2 ";
std::cout << sizeOfImage2[0] << ", " << sizeOfImage2[1] << ", " <<
sizeOfImage2[2] << std::endl <<std::endl;
// snipped a bit here that gets an indexValue of [0, 0, 0 ]
typedef itk::Index<3> indexType;
indexType blah2;
blah2 = inputIt.GetIndex();
std::cout << "index : " << blah2 << std::endl;
image->SetPixel(blah2,128);
imageMatrix[0]->SetPixel(blah2,128);
std::cout << "pixel: " << image->GetPixel(blah2) << std::endl;
This is my output:
Size2 512, 512, 52
here 2
index : [0, 0, 0]
Segmentation fault
So basically, when I'm accessing the image volume, the program crashes.
Can anybody help me with this?
cheers, Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100401/0764515d/attachment-0001.htm>
More information about the Insight-users
mailing list