2011-09-12 8 views
1

新しいアイデアがないことが数日あるので、私はあなたに伝えたいのですが問題があります。Qtのユーザーインターフェイスでitkイメージを更新する

私は、画像をダブル*ポインタと指摘している、と私はこの方法で作られた、この目的のために、ユーザーのグラフィックインターフェースを更新するためsmartpointer :: ITKにそれを翻訳したい:

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'ファイルに保存することです。 誰かが私を助けることができますか?何が正しく動作していないのアイデア?この画像ファイルを作成する機能はありますか?

+0

はあなたが画像を見ることができます:

非常に素晴らしいウィキ例でもありますか? – blueskin

+0

私はプロジェクトの冒頭にロードされた同じイメージを見ていますが、今は "新しい"イメージです。私はitkイメージへの翻訳が正しいと言います。 "aux =(* salida) - > GetPixel(pixelIndex); "適切な結果を与える – Antonio

答えて

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

+0

私はそれに取り組んでいます、あなたの助けをいただきありがとうございます、私はそれが動作する場合は教えてくれます! :) – Antonio

1

あなたはImportImageContainerを使用すると、あなたは、メモリの管理オプションの設定は非常に慎重でなければなりません。

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

この例は、「ユーザーズガイド」にあります。 http://www.vtk.org/Wiki/ITK/Examples/IO/ImportImageFilter

関連する問題