PDA

View Full Version : How to load a 3D image file in using OpenGL



dinara
06-11-2009, 06:44 PM
Hi,

First, I have not enough experience with OpenGL;

I have a problem; my goal is to calculate the MIP images of
a 3D volume image (PET image); the data is stored in a file with extension .dat (just raw data); each voxel value is represented as float number. I know that it is possible to calculate the MIP using the followuing equation:

finalColor = blendingEq(blendFunc1(src), blendFunc2(dst));

However, I do not know how to load the values of the 3D image,
according to OpenGL; in order to then apply the over mentioned equation.

Could somebody help me?

Thanks!

MaxH
06-11-2009, 07:16 PM
My first impression from reading your question is that you are vastly oversimplifying a fairly complex task. Forget about OpenGL and what you want to display for a moment. Are you able to read your voxel data with a C or C++ program? Are you aware that you are going to have to use a programming language like 'C' to read your data, do the calculations, then make the appropriate OpenGL calls to display the result? OpenGL is a library of subroutines that must be called from a programming language. It is not a standalone application or visualization package.

ZbuffeR
06-12-2009, 01:42 AM
By the way, by "MIP", you actually mean "maximum intensity projection", not the well-know-here mipmapping ("multum in parvo" mapping).

Tutorial about 3D textures :
http://gpwiki.org/index.php/OpenGL_3D_Textures

dinara
06-12-2009, 12:21 PM
Ok,

Yes I have experience in C, and C++; currecntly, I am working on
reconstruction problems; I wrote a program which is able to reconstruct data from a particular small animal PET scanner; but now I would like to visualise the 3D image obtained after the reconstruction.
To answer your questions:

Are you able to read your voxel data with a C or C++ program?
- Yes I can do that

Are you aware that you are going to have to use a programming language like 'C' to read your data, do the calculations, then make the appropriate OpenGL calls to display the result?

- Yes, I am aware; in fact, I already have the 3D image located in memory; but, I do not know how to asociate the image with the OpenGL functions; I already include the library within my program. I know that there are algorithims to calculate the MIP (I have some articles about that); but I was looking for a function in OpenGL that could help me to do that.


thanks,

dinara
06-12-2009, 12:23 PM
Yes, I am talking about Maximum Intensity Projection

ZbuffeR
06-12-2009, 12:45 PM
In OpenGL, everything is drawn as triangles.
So to draw a 3D volume, is has to be emulated.
For example, with a stack of planes, each plane facing the camera.
With blending active, and the blend equation set to max function, as you where told in your previous thread :
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=258768#Post2587 68

Start from the 3D texture example I linked above.


More clever rendering can be done using multitexturing, raycasting using GLSL shader, etc, depending on your needs and the target hardware.

MaxH
06-12-2009, 01:34 PM
... I already have the 3D image located in memory; but, I do not know how to asociate the image with the OpenGL functions; Dinara - what do you mean by 'have the 3D image located in memory'? In what form is it? Have you already done the calculations which cast rays through your 3D data, generating a 2D array which you want to display as an image? Are you asking us how to display that 2D image? Because that is trivial. OR - are you asking how to actually cast rays through your 3D data set to generate an image?

dinara
06-12-2009, 02:27 PM
Thanks for your suggestions!

dinara
06-12-2009, 03:01 PM
Dear MaxH

What do you mean for "in what form"?

I have the 3D image located in memory, each voxel is
defined by a float number, and I have a pointer given the
reference. That is what I have, the raw data. I know that I need to calculate the path of the ray through the data per angle, and that is what I am looking for, a function that could do that; but at different angles in order to get a set of 2D projection with the intention of simulate 3D animation of PET image.

I know that it is a trivial calulation when tha proyection is done along x, y and z direction; however, in order to do the animation I need projections per a sample angle.

Maybe there is no function that could do that, and I have to calculate each projection implementing a function for that.

MaxH
06-12-2009, 05:05 PM
So you're talking about doing volume visualization. It can be done via an iso-surface approach or a simplified form of raytracing (where rays aren't bounced or bent). Neither one seems trivial to me. You'd have to do quite a bit of programming on top of OpenGL to get results. Years ago I wrote an iso-surface utility. It was made up of about 10,000 lines of code. Have you considered using a scientific visualization package? I think you can get them for free from universities. Good luck.

clunis_immensus
06-17-2009, 12:06 AM
If you only want an MIP generated, without implementing it yourself, try the free version of KB-Vol3D Toolkit:

http://kbvis.com/downloads/kbvtk_2_0_eval.zip (VC++ version)
http://kbvis.com/downloads/kbvtk_2_0_eval_bc.zip
(Borland C++ Builder version)

You can add your own volume file reading code. The volume can be rendered using Colour, Grayscale, MIP or MinIP modes.