[Insight-users] Casting 3D to 2D Images with CastImageFilter Results in Error

John Drescher drescherjm at gmail.com
Thu Jun 10 12:22:56 EDT 2010


On Thu, Jun 10, 2010 at 11:47 AM, Constantine Zakkaroff
<mnkz at leeds.ac.uk> wrote:
> Yello ALL.
>
> The description for CastImageFilter says this:
>
> CastImageFilter allows the input and output image to be different
> dimensions. This is useful if you want to cast an 2D image to 3D image. The
> resulting 3D image will have a single slice. If you attempt to cast an image
> to a lower dimension, the first "slice" (or line or volume) will be
> extracted. If you want to convert an image to a lower dimension and specify
> the subspace (i.e. which slice of a volume, etc.) then you should use
> ExtractImageFilter.
>
> While it is a slightly odd thing to do, I thought it can be used as a
> shortcut to turn M*N*1-sized 3D images into M*N-sized 2D images.
>
> This code
>
> typedef itk::Image<USHORT, 3> Image2DType;
> typedef itk::OrientedImage<USHORT, 3> Image3DType;
>
> typedef itk::CastImageFilter<Image3DType, Image2DType> Cast3DTo2DFilterType;
> Cast3DTo2DFilterType::Pointer cast3DTo2DFilter =
> Cast3DTo2DFilterType::New();
> cast3DTo2DFilter->SetInput(reformattedAngioSlice);
> cast3DTo2DFilter->Update();
>
> results in error in
> UnaryFunctorImageFilter<TInputImage,TOutputImage,TFunction>
> ::GenerateOutputInformation(), when the output and input directions are
> compared. Method's code runs past the end of the output direction matrix.
>
> ... unless I'm doing something wrong with the filter.
>
> Can anyone please clarify/confirm this issue?
>

Your 2D type is really 3D

John


More information about the Insight-users mailing list