Hi all,<br><br>I'm trying to create an array of itkImages.<br><br>This is what i got so far:<br><br><br><br>int numLabels = 2;<br><br> ImageType::Pointer* imageMatrix = new ImageType::Pointer[numLabels];<br> <br> for( unsigned int i=0;i<2;i++){<br>
imageMatrix[i]= ImageType::New();<br> imageMatrix[i]->SetSpacing(sp);<br> imageMatrix[i]->SetOrigin(origin);<br> imageMatrix[i]->SetDirection(direction);<br> imageMatrix[i]->SetLargestPossibleRegion(image->GetLargestPossibleRegion());<br>
}<br><br> ImageType::SizeType sizeOfImage2 = imageMatrix[0]->GetLargestPossibleRegion().GetSize();<br> std::cout << "Size2 ";<br> std::cout << sizeOfImage2[0] << ", " << sizeOfImage2[1] << ", " << sizeOfImage2[2] << std::endl <<std::endl;<br>
<br> // snipped a bit here that gets an indexValue of [0, 0, 0 ]<br><br> typedef itk::Index<3> indexType;<br> indexType blah2;<br> blah2 = inputIt.GetIndex();<br> std::cout << "index : " << blah2 << std::endl;<br>
<br> image->SetPixel(blah2,128);<br> imageMatrix[0]->SetPixel(blah2,128);<br> std::cout << "pixel: " << image->GetPixel(blah2) << std::endl;<br><br><br><br>This is my output:<br><br>
Size2 512, 512, 52<br><br>here 2<br>index : [0, 0, 0]<br>Segmentation fault<br><br><br><br>So basically, when I'm accessing the image volume, the program crashes.<br><br>Can anybody help me with this?<br><br>cheers, Michael<br>