Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying an image with OpenGL?

Tags:

c++

opengl

I have a device to acquire XRay images. Due to some technical constrains, the detector is made of heterogeneous pixel size and multiple tilted and partially overlapping tiles. The image is thus distorted. The detector geometry is known precisely.

I need a function converting these distorted images into a flat image with homogeneous pixel size. I have already done this by CPU, but I would like to give a try with OpenGL to use the GPU in a portable way.

I have no experience with OpenGL programming, and most of the information I could find on the web was useless for this use. How should I proceed ? How do I do this ?

Image size are 560x860 pixels and we have batches of 720 images to process. I'm on Ubuntu.

like image 545
chmike Avatar asked Apr 28 '10 11:04

chmike


3 Answers

OpenGL is for rendering polygons. You might be able to do multiple passes and use shaders to get what you want but you are better off re-writing the algorithm in OpenCL. The bonus then would be you have something portable that will even use multi core CPUs if no graphics accelerator card is available.

like image 102
Goz Avatar answered Oct 12 '22 01:10

Goz


Rather than OpenGL, this sounds like a CUDA, or more generally GPGPU problem.

If you have C or C++ code to do it already, CUDA should be little more than figuring out the types you want to use on the GPU and how the algorithm can be tiled.

like image 28
Andrew McGregor Avatar answered Oct 12 '22 01:10

Andrew McGregor


If you want to do this with OpengGL, you'd normally do it by supplying the current data as a texture, and writing a fragment shader that processes that data, and set it up to render to a texture. Once the output texture is fully rendered, you can retrieve it back to the CPU and write it out as a file.

I'm afraid it's hard to do much more than a very general sketch of the overall flow without knowing more about what you're doing -- but if (as you said) you've already done this with CUDA, you apparently already have a pretty fair idea of most of the details.

like image 21
Jerry Coffin Avatar answered Oct 12 '22 00:10

Jerry Coffin