seo怎么做网站的tdk,在哪学习建网站,瑞昌网站建设,新能源汽车价格及图片目录 1、itkFlipImageFilter 图像翻转滤波器2、itkResampleImageFilter 重采样图像滤波器 1、itkFlipImageFilter 图像翻转滤波器
该类的主要功能是使输入数据在用户指定的轴上进行翻转。
翻转轴通过函数SetFlipAxes(array) 设置#xff0c;其中输入是FixArraybool,Imag… 目录 1、itkFlipImageFilter 图像翻转滤波器2、itkResampleImageFilter 重采样图像滤波器 1、itkFlipImageFilter 图像翻转滤波器
该类的主要功能是使输入数据在用户指定的轴上进行翻转。
翻转轴通过函数SetFlipAxes(array) 设置其中输入是FixArraybool,ImageDimension。 图像在 array[i] 为 true 的轴上翻转。
就网格坐标而言图像在输入图像的最大可能区域内翻转因此输出图像的 LargestPossibleRegion与输入图像相同。
就几何坐标而言输出原点是图像相对于坐标轴翻转的。
常用的成员函数
Set/GetFlipAxes()设置/获取要翻转的轴 图像沿着array[i]为true的轴翻转默认为 falseSet/GetFlipAboutOrigin()设置/获取计算的输出原点如果FlipAboutOrigin为“On”则翻转将围绕轴的原点发生如为“false”则翻转将围绕轴的中心发生默认为“On”FlipAboutOriginOn/Off()同上
示例代码
#include itkImage.h
#include itkFlipImageFilter.htypedef itk::Imageshort, 3 ShortImageType;bool flipImageFilter(ShortImageType* image, ShortImageType* outImage)
{typename FlipFilterType::FlipAxesArrayType flipArray;flipArray[0] true; //沿x轴翻转flipArray[1] false;flipArray[2] false;typedef itk::FlipImageFilterShortImageType FlipFilterType;typename FlipFilterType::Pointer flipFilter FlipFilterType::New();flipFilter-SetInput(image);flipFilter-SetFlipAxes(flipArray);flipFilter-SetFlipAboutOrigin(false); //On:围绕圆点进行翻转false围绕轴中心进行翻转默认为“On”//flipFilter-FlipAboutOriginOn(); //与SetFlipAboutOrigin功能一样//flipFilter-FlipAboutOriginOff();try{flipFilter-Update();}catch (itk::ExceptionObject ex){//读取过程发生错误std::cerr Error: ex std::endl;return false;}outImage flipFilter-GetOutput();return true;
}2、itkResampleImageFilter 重采样图像滤波器
该类通过坐标变换对图像进行重新采样并通过插值函数对图像进行插值
该类是根据输入和输出图像的类型进行模板化的
请注意插值器函数的选择可能很重要该函数通过**SetInterpolator()**进行设置。 默认为 LinearInterpolateImageFunctionInputImageType, TInterpolatorPrecisionType这对于普通医学图像来说是合理的。 然而一些合成图像的像素是从有限的指定集合中提取的 比如一个掩模它指示将大脑分割成少量的组织类型对于这样的图像一般不在不同的像素值之间进行插值NearestNeighborInterpolateImageFunctionInputImageType, TCoordRep 会是更好的选择。
如果样本是从图像域外部获取的则默认行为是使用默认像素值。 如果需要不同的行为可以使用 SetExtrapolator() 设置外推器函数。
应设置输出图像的输出信息间距、大小和方向该信息具有单位间距、零原点和同一方向的正常默认值输出信息可以从参考图像获取如果提供了参考图像并且UseReferenceImage 为“On”则将使用参考图像的间距、原点和方向。重采样是在空间坐标中执行而不是像素/网格坐标。
由于此过滤器生成的图像与其输入的大小不同因此它需要重写ProcessObject中定义的多个方法以便正确管理管道执行模型。 特别是此过滤器重写 ProcessObject::GenerateInputRequestedRegion() 和 ProcessObject::GenerateOutputInformation()。
此过滤器亦可实现多线程过滤器使用DynamicThreadedGenerateData() 方法来实现。
常用的成员函数
Set/GetInterpolator()设置/获取插值器函数默认值为 LinearInterpolateImageFunction其他选项NearestNeighborInterpolateImageFunction对于二进制蒙版和其他具有少量可能像素值的图像很有用和 BSplineInterpolateImageFunction提供更高阶的插值SetExtrapolator()设置/获取外推器函数默认值为 DefaultPixelValue其他选项NearestNeighborExtrapolateImageFunctionSetDefaultPixelValue()当设置/获取变换后的像素位于图像外部的像素值默认为 0GetOutputStartIndex()获取输出最大可能区域的起始索引Set/GetSize()设置/获取输出图像的大小Set/GetOutputDirection()设置/获取输出方向余弦矩阵Set/GetOutputOrigin()设置/获取输出图像的原点Set/GetOutputSpacing()设置/获取输出图像的像素间距SetOutputParametersFromImage()根据此图像设置输出参数的辅助方法Set/GetTransformInput()设置/获取用于重采样的坐标变换注意这必须在物理坐标中并且它是输出到输入的变换默认情况下过滤器使用身份转换如果不想使用默认的Identity转换则在尝试运行过滤器之前必须在此处提供不同的转换UseReferenceImageOn/Off()打开/关闭是否应使用指定的参考图像来定义输出信息Set/GetUseReferenceImage()同上trueOnfalseOffSet/GetReferenceImage()设置用于定义输出信息的参考图像默认情况下输出信息通过 SetOutputSpacing、SetOutputOrigin 和 SetOutputDirection 或 SetOutputParametersFromImage 方法指定此方法可用于指定要从中复制像素信息的图像必须设置UseReferenceImageOn才能使用参考图像
坐标变换 恒等变换输出图像点(x,y,x)的像素值 输入图像点(x,y,z)的像素值点坐标均为同一个空间坐标。
非恒等当输入输出图像的原点Orign和间距Space相同时从输出空间到输入空间的点映射(-30,-50,-10)的变换指输出图像点(x,y,x)的像素值输入图像点(x-30,y-50,z-10)的像素值。
恒等变换计算公式
输出图像参数 原点 orignOut {orignOut0,orignOut1,orignOut2} 间距 spaceOut {spaceOut0,spaceOut1,spaceOut2} 尺寸大小 size {sizeOut0,sizeOut1,sizeOut2}
输出图像参数 原点 orignIn {orignIn0,orignIn1,orignIn2} 间距 spaceIn{spaceIn0,space1In,spaceIn2} 尺寸大小sizeIn {sizeIn0,sizeIn1,sizeIn2}
求像素值 输出图像点I[3] {X, Y, Z}的像素将于空间坐标点 P 相关联
P 的坐标值P[3] {X*spaceOut0orignOut0, Y*spaceOut1orignOut1, Z*spaceOut2orignOut2}
P 点在输入图像对应的点 Q 坐标值为Q[3] {(P[0]-orignIn0)/spaceIn0, (P[1]-orignIn1)/spaceIn1, (P[1]-orignIn1)/spaceIn1}
如果Q不是整数坐标那么输出图像点 I 的像素值 输入图像中围绕非整数标记 Q 插入值来计算的。
示例代码
#include itkImage.h
#include itkAffineTransform.h
#include itkNearestNeighborInterpolateImageFunction.h
#include itkResampleImageFilter.htypedef itk::Imageshort, 3 ShortImageType;
typedef itk::Imagefloat, 3 FloatImageType;bool resampleImageFilter(ShortImageType* image, FloatImageType* outImage)
{double space[3] { 1,1,1 };double orign[3] { 0,0,0 };ShortImageType::SizeType size { 300,300,300 };typedef itk::ResampleImageFilterShortImageType, FloatImageType ResampleFilterType;typename ResampleFilterType::Pointer resampleFilter ResampleFilterType::New();resampleFilter-SetInput(image);//使用用来表示空间坐标类型和图像维度来定义变换类型默认的设置变换参数来表示恒等变换typedef itk::AffineTransformdouble, 3 TransformType;typename TransformType::Pointer transform TransformType::New();//typename TransformType::OutputVectorType translation;//translation[0] -30;//translation[1] -50;//translation[2] -10;//transform-Translate(translation);transform-SetIdentity();resampleFilter-SetTransform(transform); //使用用来表示空间坐标类型和图像类型来定义校对机类型typedef itk::NearestNeighborInterpolateImageFunctionShortImageType, double NNInterpolateType;typename NNInterpolateType::Pointer interpolate NNInterpolateType::New();resampleFilter-SetInterpolator(interpolate);//输出参数设置resampleFilter-SetDefaultPixelValue(0);resampleFilter-SetOutputSpacing(space);resampleFilter-SetOutputOrigin(orign);resampleFilter-SetSize(size);try{resampleFilter-Update();}catch (itk::ExceptionObject ex){//读取过程发生错误std::cerr Error: ex std::endl;return false;}outImage resampleFilter-GetOutput();return true;
}