开发者

Updating itk image in Qt user interface

I have a problem that I would like to tell you because is about some days that I don’t have new ideas.

I have an image pointed with a double* pointer, and I want to translate it into itk::smartpointer for updating the user graphic interface, for this purpose I made this method :

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
    }

}
}

And then is called here:

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

And after that, the user interface is updated:

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

The problem is that it seems that everything is working correctly, but the image in the interface is not updated. Another option also valid for my project could be to stored the image in a ‘.bmp’ or ‘.jpeg’ file. Could someone help me? Any ideas of what is not working properly? Is there any function for creating this image files?


ITK has built-in mechanisms for this, with some considerable safety advantages. Also: they can be used in a pipeline like any image source, and because they use your existing array they will be considerably faster (I think) than looping over the indices.

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


You must use the ImportImageContainer, and be very careful how you set the memory management options.

By default ITK will clean up after itself, and will expect to be able to delete the memory pointed to by your external pointer.

There are examples of this in the Users Guide.

There is also a very nice wiki example at: http://www.vtk.org/Wiki/ITK/Examples/IO/ImportImageFilter

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜