<div dir="ltr">Hi,<br><br>I'm trying to generate a vector image with the same dimensions and region as another image that I have.<br>a RT error about itkSmartPoint/ memory failure are stopping me from get this vector image<br>
<br>Here is my code, I really lost of ideas why it's happening here.<br><br>Thanks in advance.<br><br><br>my code:<br><br><br>typedef double pixelType;<br>typedef itk::Image < pixelType, myDimension > ImageType;<br>
<br>//vector Type<br>typedef itk::VectorImage < pixelType, myDimension > vectorImageType;<br><br>vectorImageType::Pointer vectorImage = vectorImageType::New();<br>ImageType::Pointer myItkImg;<br><br>//...some manipulation on myItkImg (initializing and assigning data))<br>
<br>1) first try is: <br><br> itk::CastImageFilter<ImageType,vectorImageType>::Pointer caster = itk::CastImageFilter<ImageType,vectorImageType>::New();<br><br> //cast to vector img<br> caster->SetInput(myItkImg);<br>
caster->Update();<br> vectorImage = caster->GetOutput();<br> vectorImage->SetVectorLength(vectorLength);<br> vectorImage->Allocate(); <b>//here the RT occurs</b><br><br><b>/*RT stop at this itk's internal code:</b><br>
void UnRegister()<br> {<br> if(m_Pointer) { m_Pointer->UnRegister(); }<br> }<br>*/<br><br> <br>2) second try:<br><br> vectorImageType::SizeType size;<br> <br> size[0]=myItkImg->GetDimension(0);<br>
size[1]=myItkImg->GetDimension(1);<br> size[2]=myItkImg->GetDimension(2);<br><br> ImageType::SpacingType img_spacing= myItkImg->GetSpacing();<br> vectorImageType::SpacingType vec_spacing;<br><br> vec_spacing[0]= img_spacing[0];<br>
vec_spacing[1]= img_spacing[1];<br> vec_spacing[2]= img_spacing[2];<br> <br> vectorImageType::IndexType start;<br> start.Fill(0);<br><br> vectorImageType::RegionType region(start,size);<br> vectorImage->SetSpacing(vec_spacing);<br>
vectorImage->SetRegions(region);<br> vectorImage->SetVectorLength(vectorLength);<br> vectorImage->Allocate(); <b>//here the RT occurs</b><br>/*<br><b>RT stop at this itk's internal code:</b><br> itkDebugMacro (<< "Setting imageIO IORegion to: " << m_ActualIORegion ); <br>
m_ImageIO->SetIORegion( m_ActualIORegion );<br>*/<br> <br><br></div>