它是图像梯度的x和y分量

itk x and y component of the gradient of an image

本文关键字:分量 图像      更新时间:2023-10-16

我想计算二维图像的梯度的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 ()有什么方法可以提取吗?我正在寻找它,但我没有积极的结果!

Thanks so much

安东尼奥

gradientFilter的输出将是一个矢量图像。根据你的描述,我猜是2d图像!

ImageType::IndexType index;
index[0]=xcoord;
index[1]=ycoord;
gradientFilter->GetOutput()->GetPixel(index)[0]; // will return first component of xcoord,ycoord

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

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

模板类itk:: NthElementImageAdaptor<TImage,>

表示图像由其像素的第n个元素组成。

假设像素为容器类型,并且在其API中定义了操作符[](unsigned int)。

根据c++默认类型转换规则的输入和输出图像类型执行额外的类型转换。

Wiki例子:

All Examples
Extract a component of an itkImage with pixels with multiple components
Process the nth component/element of a vector image