Skip to content

Commit

Permalink
Correct color FA for orientation as we assume gradients are in image …
Browse files Browse the repository at this point in the history
…space

git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/ttk/trunk@213 0a38917d-65eb-41a1-bb20-5b51c338416a
  • Loading branch information
ocommowi committed Dec 11, 2013
1 parent 666e75d commit 9a0dd48
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Algorithms/itkTensorToColorFAFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define _itk_TensorToColorFAFunction_h_

#include "itkTensorToScalarFunction.h"
#include <itkImageBase.h>

namespace itk
{
Expand All @@ -41,6 +42,12 @@ namespace itk
typedef TOutputPixelType OutputPixelType;

OutputPixelType ComputeScalar (const InputPixelType&) const;

void SetTransformColorWithDirection (bool value) {m_TransformColorWithDirection = value;}

typedef itk::ImageBase <3>::DirectionType MatrixType;
//! Transform used if TransformColorWithDirection is on, has to be the image direction matrix
void SetDirection(const MatrixType &matrix) {m_Direction = matrix;}

protected:
TensorToColorFAFunction(){};
Expand All @@ -55,6 +62,10 @@ namespace itk
TensorToColorFAFunction (const Self&);
void operator=(const Self&);

bool m_TransformColorWithDirection;
MatrixType m_Direction;


};


Expand Down
14 changes: 14 additions & 0 deletions Algorithms/itkTensorToColorFAFunction.txx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ namespace itk
typedef typename InputPixelType::VectorType VectorType;
VectorType vec = T.GetEigenvector (2);

if (m_TransformColorWithDirection)
{
VectorType rotatedVec = vec;

for (unsigned int i = 0;i < 3;++i)
{
rotatedVec[i] = 0;
for (unsigned int j = 0;j < 3;++j)
rotatedVec[i] += m_Direction(i,j) * vec[j];
}

vec = rotatedVec;
}

typedef typename OutputPixelType::ComponentType ComponentType;

double r = fabs (vec[0])*255.0;
Expand Down
11 changes: 10 additions & 1 deletion Commands/itkTensorToScalarCommand.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace itk
m_LongDescription = "Usage:\n";
m_LongDescription += "-i [fileIn]\n";
m_LongDescription += "-f [Function: FA / LFA / CFA / ADC / VOL / CL / CP / CS / RA / VR / L1 / L2 / L3]\n";
m_LongDescription += "-c [correct for tensor image orientation]\n\n";
m_LongDescription += "-o [fileOut]\n\n";
m_LongDescription += m_ShortDescription;
}
Expand Down Expand Up @@ -93,6 +94,7 @@ namespace itk
const char* file_in = cl.follow("NoFile", 2, "-i","-I");
const char* file_out = cl.follow("NoFile", 2, "-o","-O");
const char* function = cl.follow ("NoFunction", 2, "-f", "-F");
const bool correction = cl.search (2, "-c","-C");

if(strcmp(file_in,"NoFile")==0 || strcmp(file_out,"NoFile")==0)
{
Expand Down Expand Up @@ -252,7 +254,14 @@ namespace itk
myFilter->SetTensorToScalarFunction (myFunction);
myFilter->SetInput (io->GetOutput());


if( strcmp (function, "cfa")==0 || strcmp (function, "CFA")==0 )
{
itk::TensorToColorFAFunction<TensorImageType::PixelType, ColorImageType::PixelType> *tmpFunction = dynamic_cast <itk::TensorToColorFAFunction<TensorImageType::PixelType, ColorImageType::PixelType> *> (myColorFunction.GetPointer());

tmpFunction->SetTransformColorWithDirection(correction);
tmpFunction->SetDirection(io->GetOutput()->GetDirection());
}

try
{
myFilter->Update();
Expand Down

0 comments on commit 9a0dd48

Please sign in to comment.