Ask Your Question
0

Simple C++ lib for displaying gray-scale 2D luminance as 3D surface

asked 2019-02-24 17:55:15 -0600

Martian gravatar image

updated 2019-02-24 17:56:18 -0600

Is there a library or project that will display an OpenCV gray-scale Mat as a 3D surface? IOW, translate pixel intensity into elevation.

Example here: Look midway down the page for a surface-mapped Lena: https://stackoverflow.com/questions/3...

The solution on that page uses Python. I'd like to stay with C++, and avoid loading in large code dependencies like OpenGL, if possible. Wishful thinking, perhaps. :-)

edit retag flag offensive close merge delete

Comments

that's a somewhat unfair comparison. matplotlib has an internal 3d surface renderer builtin.

but one could take this as a hint: why try this from opencv, when you can throw it at 3rdparty programs like gnuplot ?

berak gravatar imageberak ( 2019-02-25 01:29:15 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-02-24 18:25:13 -0600

sjhalayka gravatar image

updated 2019-02-24 18:35:58 -0600

I would use a grid of triangles to approximate the surface.

image description

Do you want my code (which will take a while), or do you want to try to code it yourself?

As for display, you will need to pick some kind of graphics library. Why not OpenGL? On the PC you can use the very simple OpenGL 1.x code, which doesn't require the use of shaders, or vertex buffers, etc. Along with GLUT, and GLEW, it's practically painless. However, if you insist on going the hardcore way, you can use a math library like GLM to perform the necessary calculations yourself, like you have to do in OpenGL ES 2 or higher on the iPhone / Android.

edit flag offensive delete link more

Comments

Hi SJ, This is sort of a minor add-on to a 2D project, and will serve only for an occasional demo. I didn't want to require OpenGL for the build if it can be avoided. I've never used OpenGL, so I'm not familiar with the versions that you mention. Is OpenGL 1.x an ancient version?

Martian gravatar imageMartian ( 2019-02-24 20:52:26 -0600 )edit

Yes OpenGL 2.x came out like 15 years ago, and OpenGL 1.x is even older. The current version is 4.x.

sjhalayka gravatar imagesjhalayka ( 2019-02-25 09:26:17 -0600 )edit

My point is that OpenGL 1.x is still supported by modern drivers. It is a gentle introduction to graphics programming.

sjhalayka gravatar imagesjhalayka ( 2019-02-25 16:22:12 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-02-24 17:55:15 -0600

Seen: 269 times

Last updated: Feb 24 '19