1

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

我有一个用双 * 指针指向的图像,我想将其转换为 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 会自行清理,并期望能够删除外部指针指向的内存。

用户指南中有这方面的示例。

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

于 2011-09-23T22:33:23.957 回答