本文整理汇总了C++中GradientType类的典型用法代码示例。如果您正苦于以下问题:C++ GradientType类的具体用法?C++ GradientType怎么用?C++ GradientType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GradientType类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRandomDirection
typename AstroStickModel< ScalarType >::PixelType AstroStickModel< ScalarType >::SimulateMeasurement()
{
PixelType signal;
signal.SetSize(this->m_GradientList.size());
double b = -m_BValue*m_Diffusivity;
if (m_RandomizeSticks)
m_NumSticks = 30 + m_RandGen->GetIntegerVariate()%31;
for( unsigned int i=0; i<this->m_GradientList.size(); i++)
{
GradientType g = this->m_GradientList[i];
double bVal = g.GetNorm(); bVal *= bVal;
if (bVal>0.0001)
{
for (int j=0; j<m_NumSticks; j++)
{
double dot = 0;
if(m_RandomizeSticks)
dot = GetRandomDirection()*g;
else
dot = m_Sticks[j]*g;
signal[i] += exp( b*bVal*dot*dot );
}
signal[i] /= m_NumSticks;
}
else
signal[i] = 1;
}
return signal;
}
示例2:
typename AstroStickModel< ScalarType >::GradientType AstroStickModel< ScalarType >::GetRandomDirection()
{
GradientType vec;
vec[0] = m_RandGen->GetNormalVariate();
vec[1] = m_RandGen->GetNormalVariate();
vec[2] = m_RandGen->GetNormalVariate();
vec.Normalize();
return vec;
}
示例3: rotation
typename TensorModel< ScalarType >::PixelType TensorModel< ScalarType >::SimulateMeasurement()
{
PixelType signal;
signal.SetSize(this->m_GradientList.size());
signal.Fill(0.0);
ItkTensorType tensor;
tensor.Fill(0.0);
this->m_FiberDirection.Normalize();
vnl_vector_fixed<double, 3> axis = itk::CrossProduct(m_KernelDirection, this->m_FiberDirection).GetVnlVector();
axis.normalize();
vnl_quaternion<double> rotation(axis, acos(m_KernelDirection*this->m_FiberDirection));
rotation.normalize();
vnl_matrix_fixed<double, 3, 3> matrix = rotation.rotation_matrix_transpose();
vnl_matrix_fixed<double, 3, 3> tensorMatrix = matrix.transpose()*m_KernelTensorMatrix*matrix;
tensor[0] = tensorMatrix[0][0];
tensor[1] = tensorMatrix[0][1];
tensor[2] = tensorMatrix[0][2];
tensor[3] = tensorMatrix[1][1];
tensor[4] = tensorMatrix[1][2];
tensor[5] = tensorMatrix[2][2];
for( unsigned int i=0; i<this->m_GradientList.size(); i++)
{
GradientType g = this->m_GradientList[i];
ScalarType bVal = g.GetNorm();
bVal *= bVal;
if (bVal>0.0001)
{
itk::DiffusionTensor3D< ScalarType > S;
S[0] = g[0]*g[0];
S[1] = g[1]*g[0];
S[2] = g[2]*g[0];
S[3] = g[1]*g[1];
S[4] = g[2]*g[1];
S[5] = g[2]*g[2];
ScalarType D = tensor[0]*S[0] + tensor[1]*S[1] + tensor[2]*S[2] +
tensor[1]*S[1] + tensor[3]*S[3] + tensor[4]*S[4] +
tensor[2]*S[2] + tensor[4]*S[4] + tensor[5]*S[5];
// check for corrupted tensor and generate signal
if (D>=0)
signal[i] = exp ( -m_BValue * bVal * D );
}
else
signal[i] = 1;
}
return signal;
}
示例4: exp
ScalarType BallModel< ScalarType >::SimulateMeasurement(int dir)
{
ScalarType signal = 0;
if (dir>=this->m_GradientList.size())
return signal;
GradientType g = this->m_GradientList[dir];
ScalarType bVal = g.GetNorm(); bVal *= bVal;
if (bVal>0.0001)
signal = exp( -m_BValue * bVal * m_Diffusivity );
else
signal = 1;
return signal;
}
示例5: m_Diffusivity
AstroStickModel< ScalarType >::AstroStickModel()
: m_Diffusivity(0.001)
, m_BValue(1000)
, m_NumSticks(42)
, m_RandomizeSticks(false)
{
m_RandGen = ItkRandGenType::New();
vnl_matrix_fixed<double,3,42>* sticks = itk::PointShell<42, vnl_matrix_fixed<double, 3, 42> >::DistributePointShell();
for (int i=0; i<m_NumSticks; i++)
{
GradientType stick;
stick[0] = sticks->get(0,i); stick[1] = sticks->get(1,i); stick[2] = sticks->get(2,i);
stick.Normalize();
m_Sticks.push_back(stick);
}
}
示例6: product
ScalarType StickModel< ScalarType >::SimulateMeasurement(unsigned int dir, GradientType& fiberDirection)
{
ScalarType signal = 0;
if (dir>=this->m_GradientList.size())
return signal;
GradientType g = this->m_GradientList[dir];
if (g.GetNorm()>0.0001)
{
ScalarType dot = fiberDirection*g;
signal = std::exp( -this->m_BValue*m_Diffusivity*dot*dot ); // skip * bVal becaus bVal is already encoded in the dot product (norm of g encodes b-value relative to baseline b-value m_BValue)
}
else
signal = 1;
return signal;
}
示例7:
typename DwiPhantomGenerationFilter< TOutputScalarType >::OutputImageType::PixelType
DwiPhantomGenerationFilter< TOutputScalarType >::SimulateMeasurement(itk::DiffusionTensor3D<float>& T, float weight)
{
typename OutputImageType::PixelType out;
out.SetSize(m_GradientList.size());
out.Fill(0);
TOutputScalarType s0 = m_DefaultBaseline;
if (m_SimulateBaseline)
s0 = (GetTensorL2Norm(T)/m_MaxBaseline)*m_SignalScale;
for( unsigned int i=0; i<m_GradientList.size(); i++)
{
GradientType g = m_GradientList[i];
if (g.GetNorm()>0.0001)
{
itk::DiffusionTensor3D<float> S;
S[0] = g[0]*g[0];
S[1] = g[1]*g[0];
S[2] = g[2]*g[0];
S[3] = g[1]*g[1];
S[4] = g[2]*g[1];
S[5] = g[2]*g[2];
double D = T[0]*S[0] + T[1]*S[1] + T[2]*S[2] +
T[1]*S[1] + T[3]*S[3] + T[4]*S[4] +
T[2]*S[2] + T[4]*S[4] + T[5]*S[5];
// check for corrupted tensor and generate signal
if (D>=0)
{
D = weight*s0*exp ( -m_BValue * D );
out[i] = static_cast<TOutputScalarType>( D );
}
}
else
out[i] = s0;
}
return out;
}
示例8: exp
typename StickModel< ScalarType >::PixelType StickModel< ScalarType >::SimulateMeasurement()
{
PixelType signal;
signal.SetSize(this->m_GradientList.size());
for( unsigned int i=0; i<this->m_GradientList.size(); i++)
{
GradientType g = this->m_GradientList[i];
double bVal = g.GetNorm(); bVal *= bVal;
if (bVal>0.0001)
{
double dot = this->m_FiberDirection*g;
signal[i] = exp( -m_BValue * bVal * m_Diffusivity*dot*dot );
}
else
signal[i] = 1;
}
return signal;
}
示例9: exp
ScalarType StickModel< ScalarType >::SimulateMeasurement(unsigned int dir)
{
ScalarType signal = 0;
if (dir>=this->m_GradientList.size())
return signal;
this->m_FiberDirection.Normalize();
GradientType g = this->m_GradientList[dir];
ScalarType bVal = g.GetNorm(); bVal *= bVal;
if (bVal>0.0001)
{
ScalarType dot = this->m_FiberDirection*g;
signal = exp( -m_BValue * bVal * m_Diffusivity*dot*dot );
}
else
signal = 1;
return signal;
}
示例10:
Real
InitialConditionTempl<RealVectorValue>::dotHelper(const GradientType & op1,
const GradientType & op2)
{
return op1.contract(op2);
}