[Insight-users] generating a vector Image
David Doria
daviddoria at gmail.com
Fri May 18 08:09:35 EDT 2012
On Fri, May 18, 2012 at 5:46 AM, Hila Hiler <hilahiler at gmail.com> wrote:
> Hi,
>
> I'm trying to generate a vector image with the same dimensions and region
> as another image that I have.
> a RT error about itkSmartPoint/ memory failure are stopping me from get
> this vector image
>
> Here is my code, I really lost of ideas why it's happening here.
>
> Thanks in advance.
>
>
> my code:
>
>
> typedef double pixelType;
> typedef itk::Image < pixelType, myDimension > ImageType;
>
> //vector Type
> typedef itk::VectorImage < pixelType, myDimension > vectorImageType;
>
> vectorImageType::Pointer vectorImage = vectorImageType::New();
> ImageType::Pointer myItkImg;
>
> //...some manipulation on myItkImg (initializing and assigning data))
>
> 1) first try is:
>
> itk::CastImageFilter<ImageType,vectorImageType>::Pointer caster =
> itk::CastImageFilter<ImageType,vectorImageType>::New();
>
> //cast to vector img
> caster->SetInput(myItkImg);
> caster->Update();
> vectorImage = caster->GetOutput();
> vectorImage->SetVectorLength(vectorLength);
> vectorImage->Allocate(); *//here the RT occurs*
>
> */*RT stop at this itk's internal code:*
> void UnRegister()
> {
> if(m_Pointer) { m_Pointer->UnRegister(); }
> }
> */
>
>
> 2) second try:
>
> vectorImageType::SizeType size;
>
> size[0]=myItkImg->GetDimension(0);
> size[1]=myItkImg->GetDimension(1);
> size[2]=myItkImg->GetDimension(2);
>
> ImageType::SpacingType img_spacing= myItkImg->GetSpacing();
> vectorImageType::SpacingType vec_spacing;
>
> vec_spacing[0]= img_spacing[0];
> vec_spacing[1]= img_spacing[1];
> vec_spacing[2]= img_spacing[2];
>
> vectorImageType::IndexType start;
> start.Fill(0);
>
> vectorImageType::RegionType region(start,size);
> vectorImage->SetSpacing(vec_spacing);
> vectorImage->SetRegions(region);
> vectorImage->SetVectorLength(vectorLength);
> vectorImage->Allocate(); *//here the RT occurs*
> /*
> *RT stop at this itk's internal code:*
> itkDebugMacro (<< "Setting imageIO IORegion to: " << m_ActualIORegion );
> m_ImageIO->SetIORegion( m_ActualIORegion );
> */
>
Please make compilable examples. It is only a few more lines to produce
some dummy data and include the necessary headers. The idea is that then we
can copy/paste/compile and see the error.
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120518/ff07bd6d/attachment.htm>
More information about the Insight-users
mailing list