1

新しいアイデアが浮かばない日が数日あるので、あなたに話したい問題があります。

double* ポインターでポイントされた画像があり、それを itk::smartpointer に変換してユーザー グラフィック インターフェイスを更新したいので、この目的のために次のメソッドを作成しました。

void prueba_r01::double2itk( double *im_proc, ImageType::Pointer *salida, int alto, int ancho)
// This method translate the double* image into itk:smartpointer image
ImageType::IndexType pixelIndex; // pixelIndex[0]= index x-axis; pixelIndex[1] = index y-axisy
ImageType::PixelType pixelValue; 
ImageType::PixelType aux; //auxiliar variable for checking the behaviour of the programm

// Doing a sweep of all the image (is in double *im_proc) translating the values into itk pointer format
for (int x=0; x<ancho; x++){ // ancho: widht of the image
    pixelIndex[0]=x;//x position
    for (int y=0; y<alto; y++){ // alto: height of the image
        pixelIndex[1]=y;//y position
        pixelValue= *(im_proc+x+ancho*y);
        (*salida)->SetPixel(pixelIndex,pixelValue);
        aux = (*salida)->GetPixel(pixelIndex); // checking that the image has been correctly transtaled from im_proc to salida-- > CHECKED
    }

}
}

そして、ここで呼び出されます:

    //Translation of the double* image into itk:smartpointer image
    double2itk(out_inv, &(ui.imageframe->imagereader), alto, ancho); 

その後、ユーザー インターフェイスが更新されます。

 // Update of the image shonw in the user interface
ui.imageframe->update();

問題は、すべてが正しく機能しているように見えますが、インターフェイスの画像が更新されていないことです。私のプロジェクトにも有効な別のオプションは、画像を「.bmp」または「.jpeg」ファイルに保存することです。誰かが私を助けることができますか?何が正しく機能していないかについてのアイデアはありますか? この画像ファイルを作成する機能はありますか?

4

2 に答える 2

2

ITK には、このためのメカニズムが組み込まれており、いくつかの安全上の利点があります。また、これらは任意の画像ソースと同様にパイプラインで使用でき、既存の配列を使用するため、インデックスをループするよりもかなり高速になります (と思います)。

http://www.itk.org/Doxygen/html/classitk_1_1ImportImageFilter.html

http://www.itk.org/Doxygen/html/classitk_1_1ImportImageContainer.html

http://www.itk.org/Wiki/ITK/Examples/IO/ImportImageFilter

于 2011-09-13T15:20:10.857 に答える
1

ImportImageContainer を使用する必要があり、メモリ管理オプションの設定方法には十分注意してください。

デフォルトでは、ITK はそれ自体の後にクリーンアップし、外部ポインタが指すメモリを削除できることを期待します。

この例は、ユーザー ガイドに記載されています。

http://www.vtk.org/Wiki/ITK/Examples/IO/ImportImageFilterにも非常に優れた wiki の例があります 。

于 2011-09-23T22:33:23.957 に答える