ferluduena's picture

Is OpenTK Right for me?


I'm beginning to work on my grade thesis, and i don't have much experience in GUIs or rendering, other than basic C# forms.

What i need to do is to build a 3d volumetric reconstruction from a stack of 2D images, Basically, i will have 5 medical images of slices of an organ, the prostat for example, and what i will need to do is to allow the user to draw the organ (To set the limits) in each slice, and with this this five Rois to make a reconstruction.

Can i achieve this with OpenTK? i've been doing a lot of research on this, and seen many toolkits which are more medicine oriented, but they mostly work with DICOM formats, and for far more complex things.

Any tip on how to achieve this? I would need some kind of hint so i can begin doing research on specific ideas?

I will be working in C#, on Windows 8 x64

Thanks a lot in advance!


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Frassle's picture

It might be. There might be other frameworks more suited to this, but everything you've said can be done with OpenTK.

Showing each slice can be done by rendering a full screen textured quad and then recording mouse points where the mouse button is held down (we recently improved this on windows resulting in very smooth paths).

You can then extract a the relevant volume data using whatever algorithm is best, not a lot TK can help with there. Then extract a mesh (probably with marching cubes), again TK doesn't have this built in. Finally upload and display the mesh (maybe with some controls to change the view matrix), which can be done with TK.

Having said that, if you've never done rendering before you might be better off using a higher level framework such as MonoGame.

the Fiddler's picture

Just to add a bit of perspective: I am using OpenTK to process and visualize optical coherence tomography (OCT) volumes using C#, OpenCL and OpenGL in real time. This includes receiving data from a spectrometer, storing, processing and volume rendering via raytracing.

The application you are describing is certainly possible to implement using, for example, OpenTK and WinForms and the approach outlined by Frassle. The main challenges would be (a) implementing the volume reconstruction algorithm and (b) learning enough about 3d graphics in order to translate your high-level concepts (e.g. "select region", "display mesh") into the OpenGL command set.

If you are not familiar with volume reconstruction, or do not wish to dive into OpenGL, then I would probably suggest taking a look into the standard toolsets for medical imaging: VTK and ITK, with a sprinkling of Qt for the user interface. These come with a different set of challenges: (a) they are C++, which is not as nice as C# (to put it mildly), (b) they have a considerable learning curve. On the upside, most of the functionality you are looking for is already built-in: VTK provides widgets to draw and interact with volume slices and ITK provides methods to perform volume segmentation/reconstruction.

You do not need to mess with the DICOM format and related libraries (DCMTK etc). Your input format can be as simple or complex as you wish it to be: for example, a very simple format could be a folder of .png slices with a txt or xml file to store any metadata you need.

ferluduena's picture

Thanks a lot for your answers! You gave me a lot of new stuff to explore.

I also looked into VTK, i tried with a wrapper for C#, but had no luck.

I decided to use C#, because i had a hard time using forms with C++... i couldn't even load a .jpg and display it! Things i did effortlessly with c#, i will reevaluate this decition, may be i can do this with QT?

Thanks a lot again!

Edit: Would you recommend any particular IDE for using QT+VTK+ITK?

the Fiddler's picture

For an IDE, I'd recommend Qt Creator. It is part of the default Qt installation and it is easily the best cross-platform C++ IDE out there.

I would also recommend installing cmake for a build system. It is slightly annoying to use and has a learning curve, but it is pretty much the only sane option for VTK+ITK+Qt and will save you time in the long run. Qt Creator integrates with cmake out of the box.

Finally, I'd recommend using the native compiler for your platform: msvc on Windows, gcc on Linux or clang on Mac. This allows you to download and use prebuilt binaries for VTK, ITK, Qt - otherwise, you'd have to compile them yourself and that can easily take half a day on a fast machine. Qt Creator will automatically detect and use whichever compiler you have installed.