Archived

This topic is now archived and is closed to further replies.

cool_xo

Help ~ 3D visulisation of 2D slices

Recommended Posts

I am new to Graphics Programming. I would really appreciate if anyone can help, or give some opinion to my problem. =( At work, I''m given a task to write a software which takes in slices of 2D data files, and display them in a 3D environment. It is used for Ground Penetrating Radar stuff... like, the users can see what''s underground in 3D(where previously can only see 2D slices). I have to use VC++ & MFC(no money, no choice) and DirectX(since i''m using a ATI card)... I would like to know: (1) Basically, what should be the approach be? I don''t understand how can I change data points into a solid 3D cube. (2) Do I need to write a 3D engine myself.. since I can''t find anything in DirectX which allows me to colour in a surface pixel by pixel according to the data point''s value. Thanks in advance. I''m really puzzled.... any comments will do. thank you thank you~

Share this post


Link to post
Share on other sites
look up "voxel"

i can send you some simple sample code using directx 7 if you REALLY need some help. just email me at Raptor85@earthlink.net (i wont send you all of it, just the functions you need, then write a directdraw 7 app to use them in

___________________
-Nicholas Anton
-www.geocities.com/nickanton7/

REFUSE TO BUY WINDOWS XP! STAY WITH 98se!! MICROSOFT CUTTING SUPPORT FOR OLDER PROGRAMS IS A VERY BAD THING.

Share this post


Link to post
Share on other sites
Hey, this is my favorite topic! The words you want to look for are volume visualization, and volume rendering. You want to put all the 2d slices into a big data file. You look at this data set as if it were a 3d scalar field => accessing any coordinate will return one real number (ie f(x,y,z) = d).There are several ways to visualize volume datasets. They can be classified into two big categories. Isourface rendering, and DVR (direct volume rendering).

Isosurface rendering uses techniques (look up Marching Cubes Algorithm), to extract a surface of constant value in the data set into triangles. You can then render this mesh using opengl or something. The good thing about this type of rendering is that it is fast and can be easily accelerated by hardware.

DVR produces cooler images and conveys more data information in one image by basically rendering everything (it is not restricted to rendering just surfaces of constant value (level sets) of a data set. Methods of DVR include raytracing and splatting, which you can easily look up online. Basically, in DVR, you visualize a data set as a big glowing cube of jello, with different values being different colors and intensities. It is generally a lot slower than rendering isosurfaces, but produces better quality images.

Share this post


Link to post
Share on other sites
hmmm.... I really appreciate ur replys. But now... I''m still pretty confused since there''s 2 different methods posted by 2 diff person. =\

I''m looking up ''voxel'' and ''March Cube'' now... another thing I don''t quite understand is with using these algorithms.. how can DirectX be of any help? I know that DX can build up a mesh and stuff.... but how can I used DX to accelerate the calculation of algorithms quicker?

Oh... If there''s an 3rd opinion... I would love to hear it too.

Share this post


Link to post
Share on other sites
quote:

Oh... If there's an 3rd opinion... I would love to hear it too.


There always is

3D textures. It's a very simple and high quality way to render volumes. Put your volumetric data slices into a 3D texture. Then render view aligned 2D slices from back to front, that cut through the 3D texture. The hardware will automatically interpolate the right values from the volume. You just have to select an appropriate blend mode. Newer 3D cards have specialized blending modes for volume visualization.

The Marching cube algorithm will produce a totally different type of volume (isosurface), that might or might not be what you want. And BTW, it is patented, so be careful when using it for commercial applications inside the US. [Edit: oh, you're from down-under. It shouldn't be a problem to use there ]

/ Yann

[edited by - Yann L on September 2, 2002 10:08:42 PM]

Share this post


Link to post
Share on other sites
I have no idea what is the magnitude of the data you''re working with, but if it has a large amount of detail, it''s quite possible that 3D textures might be too slow. If this is the case, you can always save the 2D slices to their individual textures, then layer them on top of each other to create an illusion of depth. Of course, you lose a decent amount of detail going this route, but if you have a decent fill rate for your card it will almost certainly run in real time.

Share this post


Link to post
Share on other sites
In term of magnitude... say for a 1x1 meter surface, I have to sample around 40 slices in 2 directions(i.e. perpendicular to each other), which adds up to 80 slices. And for each slice the number of data points will be around 512x2048.

Is that big??

Ohh...... I need to have the functionality to do Isosurface AND just plain volumne visualisation(display like a cube). Soo... I think Match Cube maybe needed to do Isosurface then.

OH, if this is the case, should I have 2 different algorithm, one for Isosurface, and one for the cube display??

Share this post


Link to post
Share on other sites
quote:

In term of magnitude... say for a 1x1 meter surface, I have to sample around 40 slices in 2 directions(i.e. perpendicular to each other), which adds up to 80 slices. And for each slice the number of data points will be around 512x2048.

Is that big??


Yes In luminance-only mode, we''re talking about 84MB texture data here, in RGB mode it sums up to 250MB. And that''s without mipmaps. What 3D card do you want to run the whole thing on ?

quote:

Ohh...... I need to have the functionality to do Isosurface AND just plain volumne visualisation(display like a cube). Soo... I think Match Cube maybe needed to do Isosurface then.


Yes, marching cubes is definitely the best choice for isosurfaces.

quote:

OH, if this is the case, should I have 2 different algorithm, one for Isosurface, and one for the cube display??


Well, you can also visualize isosurfaces on a standard 3D data grid. But the quality of marching cubes will be far better, and it will be faster. So, yes, you should use two separate algorithms. The only problem that could arise with marching cubes is the initial processing phase. Your data set must be transformed into geoemtry before you can visualize it. So expect a serious slowdown (esp. at the resolution you need), if using animated datasets, or if changing the isosurface threshold value in realtime.

/ Yann

Share this post


Link to post
Share on other sites
I''m using the ATI RAGE Mobility 128 AGP4x card, and the client is currently using the same labtop as I''m now. Soo... I''m just a bit worried that it maybe too slow to display it.

If it''s not too much trouble, would u happen to know how DirectX can be used to make my life easier? Which part can I use DX to do it for me..... and which part do I need to write myself??

I''m new to DirectX.. so, I would like to get a better idea on what the structure and design of my software should be.

Ohh... thanks again Yann L. Ohh... or anyone that can help me too. =)

Share this post


Link to post
Share on other sites
quote:

I''m using the ATI RAGE Mobility 128 AGP4x card, and the client is currently using the same labtop as I''m now. Soo... I''m just a bit worried that it maybe too slow to display it.


Whoa, sorry, but forget it. It simply is impossible to display a high resolution volumetric dataset on such a chip. On a Rage128 you have to make a (big) trade off, there is no choice. Either reduce the quality (resolution) of your 3D dataset, or drop interactivity (realtime visualization).

I would suggest an adaptive approach. At startup, detect the type of graphics chipset. Run some tests, eg. maximum fillrate, largest texture size, available memory, etc. Then, choose an appropriate resolution for your dataset, and scale it down. Also try to use texture compression, wherever possible.

* On low end HW, you could try a resolution of eg. 256*256*80 compressed, displayed using splatting or similar. Give the user an option to display a still frame at full quality (which will take a few seconds for one frame).

* On medium level HW, you can use an adaptive degradation system: create two datasets, one at reduced resolution and one at full resolution. If the volume is in motion (ie. the user moves it around), then use the reduced dataset for fluid realtime visualization. When movement stops (ie. the user wants to contemplate a detail), the rerender the current frame at full resolution. This approach is often used in scientific / military visualization systems, when the datasets get to big to handle in full realtime.

* On highend HW, just use the full resolution dataset for interactive rendering.

quote:

If it''s not too much trouble, would u happen to know how DirectX can be used to make my life easier? Which part can I use DX to do it for me..... and which part do I need to write myself??


If you want to use marching cubes, you''ll have to code this algorithm yourself. Rendering the result is merely a simple standard 3D engine, since this algorithm will give you a trimesh as output.

As for the 3D datafield rendering, it depends on the technique you want to use. A basic volumetric renderer is not that hard to code, since normally there is not very much geometry involved. Your limit will almost always be fillrate, AGP bandwidth for texture swapping and VRAM (video memory). Try to use texture compression (DXTC), if you can. Try to avoid texture swaps. Optimizing for geometry performance, on the other hand, won''t be too interesting in your case.

/ Yann

Share this post


Link to post
Share on other sites
The shear-warp factorization that was developed by Phil Lacroute, is a pretty fast way to render entire volumes. I don't think it will give you interactivity, but it will certainly be faster than a generic splatting algorithm. It's a pretty clever but complicated algorithm to describe. His phd dissertation is online though.

[edited by - yellowjon on September 3, 2002 10:24:14 AM]

Share this post


Link to post
Share on other sites