From: eduardo.davila@creatis.insa-lyon.fr Date: Mon, 14 Apr 2025 08:30:05 +0000 (+0200) Subject: box TurnImage manual matrix type -1 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=bf4535fc2c69a9014cb59295f6315a1bbc5a0d16;p=creaVtk.git box TurnImage manual matrix type -1 --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx index 7afd2e9..2c3a8ec 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx @@ -5,9 +5,8 @@ #include "bbcreaVtkPackage.h" #include "creaVtk_MACROS.h" - -#include #include +#include namespace bbcreaVtk { @@ -106,11 +105,26 @@ void TurnImage::Process() } // for k bbSetOutputOut(newImage); */ - if ( (bbGetInputDir()==1) || (bbGetInputDir()==2) ) + if ( (bbGetInputDir()>=-1) && (bbGetInputDir()<=5) ) { vtkImageReslice *reslice = vtkImageReslice::New(); vtkImageChangeInformation *mchange = vtkImageChangeInformation::New(); // Reslice does all of the work. + if ( bbGetInputDir()==-1 ) // manual matrix + { + + if (bbGetInputAxesDirectionCosines().size()==9) + { + std::vector v =bbGetInputAxesDirectionCosines(); + double axes[3][3] = { { v[0], v[1], v[2] }, { v[3], v[4], v[5] }, { v[6], v[7], v[8] } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } + } // dir -1 + if ( bbGetInputDir()==0 ) // nothing + { + static double axes[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } // dir 0 if ( bbGetInputDir()==1 ) { static double axes[3][3] = { { 0, 1, 0 }, { 0, 0, -1 }, { 1, 0, 0 } }; @@ -121,10 +135,27 @@ void TurnImage::Process() static double axes[3][3] = { { 1, 0, 0 }, { 0, 0, -1 }, { 0, 1, 0 } }; reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); } // dir 2 + if ( bbGetInputDir()==3 ) + { + static double axes[3][3] = { { 0, 1, 0 }, { 1, 0, 0 }, { 0, 0, 1 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } // dir 3 + if ( bbGetInputDir()==4 ) // RY90 + { + static double axes[3][3] = { { 0, 0, 1 }, { 0, 1, 0 }, { -1, 0, 0 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } // dir 4 + if ( bbGetInputDir()==5 ) // RY-90 + { + static double axes[3][3] = { { 0, 0, -1 }, { 0, 1, 0 }, { 1, 0, 0 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } // dir 5 // reslice->SetOutputOrigin(0,0,0); + bbGetInputIn()->Modified(); reslice->SetInputData( bbGetInputIn() ); reslice->SetResliceAxesOrigin( 0,0,0 ); reslice->SetInterpolationModeToNearestNeighbor(); + reslice->Modified(); reslice->Update(); mchange->SetInputData( reslice->GetOutput() ); mchange->SetOutputOrigin( 0,0,0 ); @@ -132,8 +163,7 @@ void TurnImage::Process() bbSetOutputOut( mchange->GetOutput() ); } else { bbSetOutputOut( bbGetInputIn() ); - }// if Dir 1 or 2 - + }// if Dir -1..5 } else { bbSetOutputOut(NULL); }// if In!=NULL diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.h b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.h index 1f6d0f4..98eb49c 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.h @@ -24,10 +24,11 @@ class bbcreaVtk_EXPORT TurnImage //===== BBTK_DECLARE_INPUT(In,vtkImageData*); BBTK_DECLARE_INPUT(Dir,int); + BBTK_DECLARE_INPUT(AxesDirectionCosines,std::vector); BBTK_DECLARE_OUTPUT(Out,vtkImageData*); BBTK_PROCESS(Process); void Process(); -//===== +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== }; @@ -39,7 +40,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(TurnImage,bbtk::AtomicBlackBox); BBTK_CATEGORY("empty"); BBTK_INPUT(TurnImage,In,"Input Image",vtkImageData*,""); - BBTK_INPUT(TurnImage,Dir,"(default 0) 0:XY(original) 1:YZ 2:XZ",int,""); + BBTK_INPUT(TurnImage,Dir,"(default 0) -1:Manual matrix 0:XY(original) 1:YZ 2:XZ 3:R180Z 4:RY90 5:RY-90",int,""); + BBTK_INPUT(TurnImage,AxesDirectionCosines,"AxesDirectionCosines 9 elements of a matrix3x3", std::vector ,""); BBTK_OUTPUT(TurnImage,Out,"Output image",vtkImageData*,"");