1

我想计算二维图像梯度的 x 和 y 分量。如在 MATLAB 中,计算[dT2,dT1] = gradient(T);

ReaderType::Pointer T_g     // image 
FilterType::Pointer gradientFilter = FilterType::New();
gradientFilter->SetInput( T_g->GetOutput());
gradientFilter->Update();

有了这句话,我得到了结果,但是我想要有x分量和y分量的gradientFilter->GetOutput() 有什么方法可以提取出来吗?我正在寻找它,但我没有积极的结果!

非常感谢

安东尼奥

4

2 回答 2

1

gradientFilter 的输出将是一个矢量图像。根据您的描述,我假设它是 2d 图像!

ImageType::IndexType index;
index[0]=xcoord;
index[1]=ycoord;

gradientFilter->GetOutput()->GetPixel(index)[0]; // will return first component of xcoord,ycoord
于 2011-09-22T14:21:14.367 回答
1

http://www.vtk.org/Wiki/ITK/Examples

http://www.vtk.org/Wiki/ITK/Examples/ImageProcessing/NthElementImageAdaptor

模板类 itk::NthElementImageAdaptor< TImage, TOutputPixelType >

将图像表示为由其像素的第 N 个元素组成。

它假定像素是容器类型,并且在其 API 中定义了 operator[]( unsigned int )。

根据 C++ 默认转换规则根据输入和输出图像类型执行附加转换。

维基示例:

All Examples

Extract a component of an itkImage with pixels with multiple components

Process the nth component/element of a vector image
于 2011-09-23T02:34:51.063 回答