[Rtk-users] coordinates of 3D volume

Simon Rit simon.rit at creatis.insa-lyon.fr
Wed Sep 10 10:50:00 EDT 2014


This option works but there is a risk of an additional interpolation by the
resampler and it costs some computing time. The other option I suggested
requires to modify the transform parameter of the source (in this example,
add

constantImageSource->SetDirection(transform->GetMatrix());

where transform is that of Yang's example, then use
itk::ChangeImageInformation
<http://www.itk.org/Doxygen/html/classitk_1_1ChangeInformationImageFilter.html>
to reset the transform to identity.

On Wed, Sep 10, 2014 at 3:47 PM, Yang Kyun Park <theday79 at gmail.com> wrote:

> Hi Chao,
>
>
>
> I had the same issue on my work and I’ve managed to fix it by the
> following codes.
>
> I’m not sure this is the optimal way to do it but at least it worked in my
> case.
>
>
>
> (Or you can transform it in 3D Slicer.
>
> In transform menu, you need to apply the following matrix:
>
> 0 0 -1 0
>
> 1 0 0 0
>
> 0 1 0 0
>
> 0 0 0 1
>
> to the target image, harden the transform then export the image.)
>
>
>
> Best,
>
> YangKyun
>
>
>
>
>
> // OutputImageType = <float, 3>
>
> // streamerBP->GetOutput(): resultant 3D image from rtkfdk reconstruction
>
>
>
> //Same image type from original image -3D & float
>
>        OutputImageType::IndexType start_trans;
>
>        start_trans[0] = 0;
>
>        start_trans[1] = 0;
>
>        start_trans[2] = 0;
>
>
>
>        OutputImageType::SizeType size_trans;
>
>        size_trans[0] = sizeOutput[0]; // X //410
>
>        size_trans[1] = sizeOutput[2]; //Y  // 410
>
>        size_trans[2] = sizeOutput[1]; //Z // 120?
>
>
>
>        OutputImageType::SpacingType spacing_trans;
>
>        spacing_trans[0] = spacing[0];
>
>        spacing_trans[1] = spacing[2];
>
>        spacing_trans[2] = spacing[1];
>
>
>
>        OutputImageType::PointType Origin_trans;
>
>        Origin_trans[0] = -0.5* size_trans[0]*spacing_trans[0];
>
>        Origin_trans[1] = -0.5* size_trans[1]*spacing_trans[1];
>
>        Origin_trans[2] = -0.5* size_trans[2]*spacing_trans[2];
>
>
>
>        OutputImageType::RegionType region_trans;
>
>        region_trans.SetSize(size_trans);
>
>        region_trans.SetIndex(start_trans);
>
>
>
>        /* 2) Prepare Target image */
>
>        OutputImageType::Pointer targetImg = streamerBP->GetOutput();
>
>
>
>        /* 3) Configure transform */
>
>        typedef itk::Euler3DTransform< double > TransformType;
>
>        TransformType::Pointer transform = TransformType::New();
>
>
>
>        TransformType::ParametersType param;
>
>        param.SetSize(6);
>
>        //MAXIMUM PARAM NUMBER: 6!!!
>
>        param.put(0, 0.0); //rot X // 0.5 = PI/2
>
>        param.put(1,  itk::Math::pi/2.0);//rot Y
>
>        param.put(2,  itk::Math::pi/-2.0);//rot Z
>
>        param.put(3, 0.0); // Trans X mm
>
>        param.put(4, 0.0); // Trans Y mm
>
>        param.put(5, 0.0); // Trans Z mm
>
>
>
>        TransformType::ParametersType fixedParam(3); //rotation center
>
>        fixedParam.put(0,0);
>
>        fixedParam.put(1,0);
>
>        fixedParam.put(2,0);
>
>
>
>        transform->SetParameters(param);
>
>        transform->SetFixedParameters(fixedParam); //Center of the
> Transform
>
>
>
>        cout << "Transform matrix:" << "  " << endl;
>
>        cout << transform->GetMatrix() << std::endl;
>
>
>
>        typedef itk::ResampleImageFilter<OutputImageType, OutputImageType>
> ResampleFilterType;
>
>        ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>
>        //OutputImageType::RegionType fixedImg_Region =
> fixedImg->GetLargestPossibleRegion().GetSize();
>
>
>
>        resampler->SetInput(targetImg);
>
>        resampler->SetSize(size_trans);
>
>        resampler->SetOutputOrigin( Origin_trans); //Lt Top Inf of Large
> Canvas
>
>        resampler->SetOutputSpacing( spacing_trans ); // 1 1 1
>
>        resampler->SetOutputDirection( targetImg->GetDirection() ); //image
> normal?
>
>        resampler->SetTransform(transform);
>
>
>
>        //LR flip
>
>
>
>        cout << "LR flip filter is being applied" << endl;
>
>
>
>        typedef itk::FlipImageFilter< OutputImageType >  FilterType;
>
>
>
>        FilterType::Pointer flipFilter = FilterType::New();
>
>        typedef FilterType::FlipAxesArrayType FlipAxesArrayType;
>
>
>
>        FlipAxesArrayType arrFlipAxes;
>
>        arrFlipAxes[0] = 1;
>
>        arrFlipAxes[1] = 0;
>
>        arrFlipAxes[2] = 0;
>
>
>
>        flipFilter->SetFlipAxes(arrFlipAxes);
>
>        flipFilter->SetInput(resampler->GetOutput());
>
> flipFilter->Update();
>
>
>
> //Use flipFilter->GetOutput() for further process
>
>
>
>
>
>
>
> *From:* Rtk-users [mailto:rtk-users-bounces at public.kitware.com] *On
> Behalf Of *Simon Rit
> *Sent:* Wednesday, September 10, 2014 8:39 AM
> *To:* Chao Wu
> *Cc:* rtk-users at openrtk.org
> *Subject:* Re: [Rtk-users] coordinates of 3D volume
>
>
>
> Hi,
>
> I wish there was a single industrial standard... You have the DICOM
> standard in mind and I used an IEC standard (see wiki). You can play with
> the --direction option to orientate the voxel axes of your image (see
> itk::Image documentation) and then reset the direction of your output image
> to identity, I think that will do what you want.
>
> Simon
>
>
>
> On Wed, Sep 10, 2014 at 1:35 PM, Chao Wu <wuchao04 at gmail.com> wrote:
>
> Hi all,
>
>
>
> I see that rtk use certain industrial standard for the coordinates of 2D
> projections and 3D volumes. However in medical imaging, the xy planes of a
> volume are usually transaxial slices while the 3rd dimension is aligned
> with the axis of rotation. I would like to switch to this coordinates in my
> own code. Is there anyone who can give me some comments and suggestions
> about where to start? Thanks.
>
>
>
> Regards,
>
> Chao
>
>
> _______________________________________________
> Rtk-users mailing list
> Rtk-users at public.kitware.com
> http://public.kitware.com/mailman/listinfo/rtk-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/rtk-users/attachments/20140910/94e37f13/attachment-0009.html>


More information about the Rtk-users mailing list