1

ヘッダー ファイルで、このすべてのタイプを宣言します。「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 」 そして何か奇妙なものを見ますか?または、勾配を計算する過程で?

本当にありがとう!

アントニオ

4

2 に答える 2

2

ITK は、計算でボクセル間隔を尊重する必要があります。画像に等方性の単位間隔がありますか?

これにより、matlab との違いが説明できます。

于 2011-09-28T22:02:52.093 に答える
1

次の行を追加するだけで、問題は画像の間隔にありました。

gradientFilter->SetUseImageSpacingOff(); // for derivation in isotropic pixel space

問題は解決され、導出は等方性空間で行われました

于 2011-10-05T14:57:15.837 に答える