Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging of image processing code

What kind of debugging is available for image processing/computer vision/computer graphics applications in C++? What do you use to track errors/partial results of your method?

What I have found so far is just one tool for online and one for offline debugging:

  1. bmd: attaches to a running process and enables you to view a block of memory as an image
  2. imdebug: enables printf-style of debugging

Both are quite outdated and not really what I would expect.

What would seem useful for offline debugging would be some style of image logging, lets say a set of commands which enable you to write images together with text (probably in the form of HTML, maybe hierarchical), easy to switch off at both compile and run time, and the least obtrusive it can get.

The output could look like this (output from our simple tool):
http://tsh.plankton.tk/htmldebug/d8egf100-RF-SVM-RBF_AC-LINEAR_DB.html

Are you aware of some code that goes in this direction?

I would be grateful for any hints.

like image 248
tsh Avatar asked Aug 25 '11 09:08

tsh


2 Answers

Coming from a ray tracing perspective, maybe some of those visual methods are also useful to you (it is one of my plans to write a short paper about such techniques):

  1. Surface Normal Visualization. Helps to find surface discontinuities. (no image handy, the look is very much reminiscent of normal maps)

    color <- rgb (normal.x+0.5, normal.y+0.5, normal.z+0.5)

  2. Distance Visualization. Helps to find surface discontinuities and errors in finding a nearest point. (image taken from an abandoned ray tracer of mine)

    color <- (intersection.z-min)/range, ...

    enter image description here

  3. Bounding Volume Traversal Visualization. Helps visualizing a bounding volume hierarchy or other hierarchical structures, and helps to see the traversal hotspots, like a code profiler (e.g. Kd-trees). (tbp of http://ompf.org/forum coined the term Kd-vision).

    enter image description hereenter image description here

    color <- number_of_traversal_steps/f

  4. Bounding Box Visualization (image from picogen or so, some years ago). Helps to verify the partitioning.

    enter image description here

    color <- const

  5. Stereo. Maybe useful in your case as for the real stereographic appearance. I must admit I never used this for debugging, but when I think about it, it could prove really useful when implementing new types of 3d-primitives and -trees (image from gladius, which was an attempt to unify realtime and non-realtime ray tracing)

    enter image description here

    You just render two images with slightly shifted position, focusing on some point

  6. Hit-or-not visualization. May help to find epsilon errors. (image taken from metatrace)

    http://th01.deviantart.net/fs70/PRE/f/2010/309/b/0/debugging_a_c___in_s_anity_by_phresnel-d327c6w.png

    if (hit) color = const_a; else color = const_b

  7. Some hybrid of several techniques.

    1. Linear interpolation: lerp(debug_a, debug_b)
    2. Interlacing: if(y%2==0) debug_a else debug_b
    3. Any combination of ideas, for example the color-tone from Bounding Box Visualization, but with actual scene-intersection and lighting applied

You may find some more glitches and debugging imagery on http://phresnel.org , http://phresnel.deviantart.com , http://picogen.deviantart.com , and maybe http://greenhybrid.deviantart.com (an old account).

like image 140
Sebastian Mach Avatar answered Nov 03 '22 14:11

Sebastian Mach


Generally, I prefer to dump bytearray of currently processed image as raw data triplets and run Imagemagick to create png from it with number e.g img01.png. In this way i can trace the algorithms very easy. Imagemagick is run from the function in the program using system call. This make possible do debug without using any external libs for image formats.

Another option, if you are using Qt is to work with QImage and use img.save("img01.png") from time to time like a printf is used for debugging.

like image 44
Ross Avatar answered Nov 03 '22 14:11

Ross