本文整理汇总了C++中Matrix::At方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::At方法的具体用法?C++ Matrix::At怎么用?C++ Matrix::At使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::At方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
boolean Matrix<T_VALUE, R_SIZE, C_SIZE>::operator !=(const Matrix<T_VALUE,R_SIZE,C_SIZE>& REF) const
{
for(size R_ITER=0;R_ITER!=R_SIZE;++R_ITER)
for(size C_ITER=0;C_ITER!=C_SIZE;++C_ITER)
if(At(R_ITER, C_ITER)!=REF.At(R_ITER, C_ITER))
return true;
}
示例2: T
inline Vector<T, Rows> operator * (
const Matrix<T, Rows, N>& m,
const Vector<T, N>& v
)
{
T tmp[Rows];
for(std::size_t r=0; r!=Rows; ++r)
{
tmp[r] = T(0);
for(std::size_t c=0; c!=N; ++c)
{
tmp[r] += m.At(r, c) * v.At(c);
}
}
return Vector<T, Rows>(tmp);
}
示例3:
/**
* @brief 3D resample data to new grid size
*
* @param M Incoming data
* @param f Resampling factor in all 3 dimensions
* @param im Interpolation method (LINEAR|BSPLINE)
*
* @return Resampled data
*/
template<class T> static Matrix<T>
resample (const Matrix<T>& M, const Matrix<double>& f, const InterpMethod& im) {
Matrix <T> res = M;
#ifdef HAVE_INSIGHT
typedef typename itk::OrientedImage< T, 3 > InputImageType;
typedef typename itk::OrientedImage< T, 3 > OutputImageType;
typedef typename itk::IdentityTransform< double, 3 > TransformType;
typedef typename itk::LinearInterpolateImageFunction< InputImageType, double > InterpolatorType;
typedef typename itk::ResampleImageFilter< InputImageType, InputImageType > ResampleFilterType;
typename InterpolatorType::Pointer linterp = InterpolatorType::New();
TransformType::Pointer trafo = TransformType::New();
trafo->SetIdentity();
typename InputImageType::SpacingType space;
space[0] = 1.0/f[0];
space[1] = 1.0/f[1];
space[2] = 1.0/f[2];
typedef typename InputImageType::SizeType::SizeValueType SizeValueType;
typename InputImageType::SizeType size;
size[0] = static_cast<SizeValueType>(res.Dim(0));
size[1] = static_cast<SizeValueType>(res.Dim(1));
size[2] = static_cast<SizeValueType>(res.Dim(2));
typename itk::OrientedImage< T, 3 >::Pointer input = itk::OrientedImage< T, 3 >::New();
typename itk::OrientedImage< T, 3 >::Pointer output = itk::OrientedImage< T, 3 >::New();
typename itk::Image< T, 3 >::IndexType ipos;
ipos[0] = 0; ipos[1] = 0; ipos[2] = 0;
typename itk::Image< T, 3 >::IndexType opos;
opos[0] = 0; opos[1] = 0; opos[2] = 0;
typename itk::Image< T, 3 >::RegionType ireg;
ireg.SetSize(size);
ireg.SetIndex(ipos);
input->SetRegions(ireg);
input->Allocate();
typename itk::Image< T, 3 >::RegionType oreg;
oreg.SetSize(size);
ireg.SetIndex(opos);
output->SetRegions(oreg);
output->Allocate();
for (size_t z = 0; z < res.Dim(2); z++)
for (size_t y = 0; y < res.Dim(1); y++)
for (size_t x = 0; x < res.Dim(0); x++) {
ipos[0] = x; ipos[1] = y; ipos[2] = z;
input->SetPixel (ipos, res.At(x,y,z));
}
typename ResampleFilterType::Pointer rs = ResampleFilterType::New();
rs->SetInput( input );
rs->SetTransform( trafo );
rs->SetInterpolator( linterp );
rs->SetOutputOrigin ( input->GetOrigin());
rs->SetOutputSpacing ( space );
rs->SetOutputDirection ( input->GetDirection());
rs->SetSize ( size );
rs->Update ();
output = rs->GetOutput();
res = Matrix<T> (res.Dim(0)*f[0], res.Dim(1)*f[1], res.Dim(2)*f[2]);
res.Res(0) = res.Res(0)/f[0];
res.Res(1) = res.Dim(1)/f[1];
res.Res(2) = res.Dim(2)/f[2];
for (size_t z = 0; z < res.Dim(2); z++)
for (size_t y = 0; y < res.Dim(1); y++)
for (size_t x = 0; x < res.Dim(0); x++) {
opos[0] = x; opos[1] = y; opos[2] = z;
res.At(x,y,z) = output->GetPixel (opos);
}
#else
printf ("ITK ERROR - Resampling not performed without ITK!\n");
#endif
return res;
}