ヘッダー ファイルで、このすべてのタイプを宣言します。「Gradient ImageFilter」は 2D 画像のグラデーションを計算するためのもので、「VectorIndexSelectionCastImageFilter」はグラデーション計算の 'x' および 'y' コンポーネントを選択するためのものです。勾配を計算した結果がベクトル画像であるという事実に。
typedef double operatorValueType;
typedef double outputValueType;
typedef double InputPixelType;
typedef itk::Image<InputPixelType, 2> InputImageType;
typedef itk::GradientImageFilter< InputImageType, operatorValueType, outputValueType> GradientFilterType;
//for extracting a scalar from the vector image
typedef double OutputPixelTypeImage;
typedef double ComponentType;
typedef itk::CovariantVector<ComponentType,2> OutputPixelType;
typedef itk::Image <OutputPixelType, 2> OutputImageType;
typedef itk::VectorIndexSelectionCastImageFilter<OutputImageType,InputImageType> SelectionFilterType; // < intputType , outputType>
宣言の後、コードの重要な部分は次のとおりです。
GradientFilterType::Pointer gradientFilter = GradientFilterType::New();
gradientFilter->SetInput(T_g->GetOutput()); // From T_g (is a reader) comes the image
gradientFilter->Update();
SelectionFilterType::Pointer componentExtractor_x = SelectionFilterType::New();
SelectionFilterType::Pointer componentExtractor_y = SelectionFilterType::New();
componentExtractor_x->SetIndex(0);// x component of the gradient
componentExtractor_y->SetIndex(1);// y component of the gradient
componentExtractor_x->SetInput(gradientFilter->GetOutput());
componentExtractor_y->SetInput(gradientFilter->GetOutput());
componentExtractor_x->Update();
componentExtractor_y->Update();
すべてが正常に機能しているように見えますが、問題は、画像を読み込んで、Matlab の勾配の計算と比較すると (これは正しいと思います)、結果が完全に異なることです...誰もが「VectorIndexSelectionCastImageFilter 」 そして何か奇妙なものを見ますか?または、勾配を計算する過程で?
本当にありがとう!
アントニオ