[Vv] Bug in clitkCropImage with the --like option

Thomas BAUDIER thomas.baudier at creatis.insa-lyon.fr
Mon Sep 30 17:05:45 CEST 2019


Hi Benoit,

Thank you for your contribution, I integrated it in the github

I'm doing test to integrate your modification about 
clitkDicomRTStruct2Image

Thank you
Thomas

On 2019-09-26 13:59, Benoît Presles wrote:
> Dear Thomas,
> 
> A quick email just to inform you that there is a bug in the
> clitkCropImage tool with the --like option. Indeed, the output image
> has always an identity direction cosines matrix even if the like image
> does not have an identity direction cosines matrix.
> 
> To correct the bug, I updated the itk/clitkCropLikeImageFilter.txx
> file as follows:
> 
> @@ -101,14 +101,19 @@ GenerateOutputInformation() {
>    // Get input info
>    typename ImageType::SizeType likeSize;
>    typename ImageType::IndexType likeStart;
> -  typename ImageType::PointType likeOrigin;
> -  typename ImageType::SpacingType likeSpacing;
> -  if (m_LikeImage) {
> +  typename ImageType::PointType likeOrigin;
> +  typename ImageType::SpacingType likeSpacing;
> +  typename ImageType::DirectionType likeDirection;
> +  typename ImageType::DirectionType like_invDirection;
> +  if (m_LikeImage) {
>      likeSize = m_LikeImage->GetLargestPossibleRegion().GetSize();
>      likeStart = m_LikeImage->GetLargestPossibleRegion().GetIndex();
>      likeOrigin = m_LikeImage->GetOrigin();
>      likeSpacing = m_LikeImage->GetSpacing();
> -    output->CopyInformation(m_LikeImage);
> +    likeDirection = m_LikeImage->GetDirection();
> +    //I don't know really why I need the inverse...
> +    like_invDirection = likeDirection.GetInverse();
> +    //output->CopyInformation(m_LikeImage);
>    }
>    else {
>      // Only load the header (allows to use 'like' with any image type)
> @@ -119,7 +124,11 @@ GenerateOutputInformation() {
>          likeStart[i] = 0;//header->GetIORegion().GetIndex()[i];
>          likeOrigin[i] = header->GetOrigin(i);
>          likeSpacing[i] = header->GetSpacing(i);
> +        for(unsigned int j=0; j<ImageType::ImageDimension; j++)
> +            likeDirection[i][j] = header->GetDirection(i)[j];
>        }
> +      //I don't know really why I need the inverse...
> +      like_invDirection = likeDirection.GetInverse();
>      }
>      else {
>        clitkExceptionMacro("You should provide SetCropLikeFilename or
> SetCropLike to CropLikeImageFilter");
> @@ -150,8 +159,9 @@ GenerateOutputInformation() {
>    output->SetRegions(m_OutputRegion);
>    output->SetRequestedRegion(m_OutputRegion);
>    output->SetBufferedRegion(m_OutputRegion);
> -  output->SetSpacing(likeSpacing);
> +  output->SetSpacing(likeSpacing);
>    output->SetOrigin(likeOrigin);
> +  output->SetDirection(like_invDirection);
>    output->Allocate(); // Needed ?
> 
>    // get startpoint source/dest
> 
> 
> 
> Best regards,
> Ben
> 
> _______________________________________________
> vv mailing list
> vv at creatis.insa-lyon.fr
> https://www.creatis.insa-lyon.fr/mailman/listinfo/vv


More information about the vv mailing list