更新itk图像在Qt用户界面

Updating itk image in Qt user interface

本文关键字:Qt 用户界面 图像 itk 更新      更新时间:2023-10-16

我有一个问题,我想告诉你,因为有几天我没有新的想法。

我有一个双*指针指向的图像,我想把它转换成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
    }
}
}

then在这里被调用:

    //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 '文件中。有人能帮帮我吗?知道是什么出了问题吗?是否有创建这个图像文件的函数?

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

您必须使用importtimagecontainer,并且在设置内存管理选项时要非常小心。

默认情况下,ITK将在自己之后进行清理,并期望能够删除外部指针指向的内存。

用户指南中有这样的例子。

还有一个很好的wiki示例:http://www.vtk.org/Wiki/ITK/Examples/IO/ImportImageFilter