PDA

View Full Version : Operations in an image opened using VTK, Qt and QVTKWidget



brenno
2nd April 2012, 16:32
How do i do to use in an image opened (from a VTK image using QVTKWidget) some operations like write, draw, create an image with zoom and create circles and polygons lines? And then export it to other image format like jpeg for example. (Using VTK, Qt and QVTKWidget).

*I already can to open the image using VTK and QVTKWidget what i need it to do the others operations.

d_stranz
3rd April 2012, 02:42
You need to learn how to use VTK to do that. QVTKWidget is simply an interface to VTK that allows a vtkRenderWindow to be hosted inside a QWidget. If you draw into this widget using Qt, VTK will know nothing about that; likewise, Qt does not know anything about what VTK is drawing in the widget. So if you want to be able to interactively draw on the VTK window and be able to save everything to jpeg, you have to do it using VTK, not Qt.

You could also capture the QVTKWidget contents to a QImage after rendering is complete, then draw on the QImage using Qt. Here (https://github.com/commontk/CTK/blob/master/Libs/Visualization/VTK/Widgets/ctkVTKWidgetsUtils.cpp) is a link to code that can capture the VTK image to a QImage. The VTK documentation has a similar example here (https://github.com/commontk/CTK/blob/master/Libs/Visualization/VTK/Widgets/ctkVTKWidgetsUtils.cpp).

brenno
4th April 2012, 18:01
I made the transformation from VTK image to QImage but when I put this image on a QLabel what I see is not the right image, there are some superpositions and errors. Here 7561 is how it would be. And Here 7562 is how it is. And I can't use the method to transform QImage from Widget ( QImage ctk::grabVTKWidget(QWidget* widget, QRect rectangle) ) because I'don't know what it necessary to match the QRect with the QWidget and how to do it.