c++ - 在 Qt 用户界面中更新 itk 图像

标签 c++ qt user-interface itk

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

我有一个用双* 指针指向的图像,我想将它转换为 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”文件中。 有人可以帮我吗?关于什么不能正常工作的任何想法?有创建这个图像文件的函数吗?

最佳答案

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

关于c++ - 在 Qt 用户界面中更新 itk 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7387846/

相关文章:

c++ - Qt中声子音频播放器的循环问题

c++ - Qt C++ - 如何获取 QPlainTextEdit 的当前行和列

ruby-on-rails - 在 Ruby 架构中处理 UI 层的最佳方式

ios - 如何将导航按钮一直限制在左侧或右侧? (iOS)

c++ - 通过 C++ 在 csv 中插入值

c++ - 如何在C++中使用无锁循环缓冲区实现零拷贝tcp

c++ - Qt UI Generator 不释放资源

c++ - big_endian 检查的 c++ 程序中没有输出

java - 为什么这个float操作在C++和Java中给出不同的结果?

java - 使用线程进行GUI编程时监听器的机制是什么?