Image Manipulation using OpenGL

Introduction

This is an imaging application designed to take advantage of OpenGL rendering capabilities for use in two-dimensional image processing. This program was developed and written during a programming student project at our Computer Graphics Department in winter 2001/2002.

It is platform-independent and runs fine under Windows and Linux; we believe it can probably be compiled on other Unices as well.

Quick Overview of the Program

Much of the main window is taken by a rendering viewport. All graphic output from effects is displayed here, and the viewport also provides a virtual trackball, so the scene can be rotated arbitrarily. In the upper-right corner is the primary controls group, most of which are self-explanatory (please note that "Play", "Pause", and "Stop" controls are not used in those effects that have no animation capability).

One control, which deserves a more detailed explanation here, is "Load Images". This allows you to load single images or entire animation sequences. The loading dialog may be shown up to 3 times, depending on how a particular effect uses image data. For example, the "B-Spline Warp" requires 2 images (or image sequences): one for the morph source and one for the morph target. If any of these dialogs gets canceled or no files are selected for loading, then you will only see a white rectangle, since most effects are only fully visible when all images needed are present.

The middle portion of the right part of the GUI is empty upon startup. It will be populated by the specific controls of the effect you select. Alternatively, these controls may appear in an extra window, depending on how the programmer of that effect decided. In that case, it might happen that this extra window is hidden by the main window, if your screen resolution is less than 1024x768. The effect-specific controls are described in detail in corresponding effect documentation in subdirectory doc in the Tar archive.

The large square button with sort of an "orbits" icon, can be toggled. When on,it turns the image viewport into a virtual trackball. All rotations are performed using the left mouse button. The axis tripod in the lower-right corner of the view shows the current orientation of the coordinate system. The reset controls reset the camera orientation and field-of-view (zoom). The red and green axes in the center of the viewport are the x- and y-axes of the coordinate system. They can be used to "lock" onto a primary axis for precise rotation. This works in the following way: when the mouse cursor is placed on the green or red axis, or on their intersection, it will change shape automatically to signify the "locked" rotation axis. The lock is possible on any of the three primary axes. Using the right mouse button you can zoom in and out.

The "Perspective View" button toggles between orthographic and perspective projection.

The lower part contains a "memory usage meter" and a small status window where effects may output various diagnostic messages or notifications. The memory meter shows how much memory is currently available and how much is taken in total by all programs and the system (for now, it is only available under Windows.)

Download

Linux executables imogl_linux_x11.tar.gz 1.1 (MB)
Windows 2000 executable imogl_win32.tar.gz 1.8 (MB)
Source code imogl_devel.tar.gz 0.7 (MB)
Test images imogl_img.tar.gz 3.3 (MB)
Test image sequence imogl_seq.tar.gz 14 (MB)

Prerequisites for running the program

Linux
glibc 2.2, Qt 2.3, OpenGL 1.2 (e.g., Mesa 3.4).
Tested and compiled on RedHat 7.2
Windows 2000
OpenGL 1.1 or higher (with 1.1, one of the effects, the "shadow caster", will probably run slower).
The Program should also run under Win98/Me.

Short Introduction to Effects

Water waves

This effect allows you to define several source points on the grid surface. These are the source of harmonic oscillations that also interfere with each other and create distortions that closely resemble waves and ripples on water surfaces. The effect is fully animated and allows you to control various parameters of the waves and their interaction.

Note: This effect will require a fast CPU if you want to achieve smooth animation at higher settings of the "Resolution" parameter.
The images show the water waves effect on several different source images. Here, only the Cygnus Loop is shown undistorted. A side view of the surface, with texture applied, being deformed by a single radial ripple wave emanating from the center. (Orig. image: Tarantula nebula) The effect has been switched into distortion mode and shows the interaction of two waves emanating from sources located at the edges. (Orig. image: dust cloud) Image of the Cygnus Loop being distorted by a single wave (in normal mode), originating from the lower-right corner. This time, damping has been turned on - notice how the distortion is more pronounced in the corner that in the center of the image.

Lights and Shadows

This uses fractal-based geometry and dynamic lighting calculations to cast shadows on any two-dimensional image. It also has the ability to utilize shadow maps if the graphic hardware supports them (e.g., GeForce3 and higher, or Radeon 8500 or higher, and maybe others). The effect is highly configurable and can produce many intriguing shadow patterns. They are best observed in orthographic projection mode, which "hides" the underlying three-dimensional geometry and creates an impression of a realistic shadow pattern on an otherwise two-dimensional image.

Note: Please keep in mind that rendering in this effect has been optimized for Nvidia chipsets, so if you don't run this on an Nvidia-based graphics card, the rendering performance may be impaired, depending on the CPU speed of your machine.
Tarantula Nebula A shadow pattern applied to the Tarantula Nebula. The image has been taken in orthographic mode. (You may have to look carefully to notice the difference to the original image). The rendering has been switched to "Metal Foil" mode and now clearly exhibits shadows on the underlying three-dimensional terrain object. The aforementioned terrain object as seen from the side. This image has been taken while in perspective mode (otherwise the orthographic projection tends to "flatten out" certain surface features).

Accumulation Buffer

Here, the OpenGL accumulation buffer is used to subtract/add images from one another or to produce motion blur effects on animated sequences.

Note: The implementation does not utilize any buffer-to-texture paths on the graphics card, if any. So the performance is not very fast.
Spiral galaxy NGC 4414. Notice how most of the background stars are gone as a result of image subtraction. Here the subtraction of the image of NGC 4414 from the Tarantula Nebula has resulted in clearly visible "hole" in the nebula. The image of Eskimo Nebula NGC2392 was added to the image of Tarantula Nebula. The result appears brighter because of the combined brightness of the two source images.

Contour Warping

This effect allows you to draw an arbitrary polygon contour on the image. In warp mode, as the polygon is scaled, rotated, and translated by the user, the image is "warped" accordingly (modifications can also be applied to individual nodes of the polygon).
Star Birth Clouds M16. A simple line segment has been rotated about the center of the image, which has an effect of "swirling" the image. (The original line is the blue segment). The same line segment, this time scaled down. The resulting image is pinched towards the center.

B-Spline Warping

This effect is actually "two effects in one": in deformation mode, it allows you to use a control grid to deform an image (or image sequence), very similar to Kay's Power Goo.

In morphing mode, it additionally performs blending between images. In a source image and a, possibly different, target image, you can draw a polygon; for both, you specify keyframes. The effect will warp the source image into the target image according to the polygon, and blend them between the two keyframes according to the time.
Eskimo Nebula NGC2392 The controlling lattice with 8 vertices selected and translated away from their original positions. ...the resulting deformation of the image mesh. ... and the effect on the source image. The Eskimo nebula has now got a pair of "ears" and now looks more like a "Bear Nebula".

Writing your own Image Manipulation Effect

The entire application is written in C++ and is based on the Trolltech's Qt application framework and OpenGL, which make it portable to many platforms.

The base directory contains a readme file where you will find the instructions on how to build and run the application in Windows and Linux.

Root of the whole system is an abstract base class GLEffect, which provides most basic functions required for rendering, mouse, and keyboard event handling etc. Every manipulation effect (i.e., feature) is derived from this base class.

The program documentation contained in the /docs subdirectory has a tutorial section that will show you how to derive a very basic effect class. Starting from the index.html, you can find links to in-depth documentation of the framework, and all other effect classes. Additionally, examine the sources of the effects that come with the program, as many parts of these can be used as a base for your own code. They have been designed by various students and contain a lot of helpful hints and information.

The effect sources are well documented, partly in English, partly in German, depending on who wrote them. Hopefully this will not hinder anyone to understand the source code. :)

Remarks

In the /src subdirectory, the sources of SampleEffect and SampleEffect2 classes, which have been excluded from the application, contain some rather simple code, which I used to test the rendering and effect control. Look into them, you might find some useful code.

Your feedback is important! We would welcome any comments, remarks, bug reports etc. concerning this application. This will give us a chance to improve it and make it more stable (perhaps even enhance it someday?). We have tried our best to remove all bugs known up to this moment.

License

THIS PROGRAM IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

The sources are provided under the terms of the General Public License. A copy of the GPL can be found in the source directory.

Copyright © 2001 by Ibragium Kouliev for the framework application. All Rights Reserved.

All stellar images are courtesy of NASA (all of them are public domain, as far as we know). All other images, including those in the Tar files, are from the Net, and, to our best knowledge, in the public domain. Should any legal issues arise, please notify us, and we will remove them.

Notice about the Manta Ray logotype image: To our best knowledge, "Manta Ray Research" is not a registered company name and/or trademark of any kind. Should any legal dispute arise, we shall promptly remove or change this name.

Credits

Ibragim Kouliev Framework and Integration
Michael Nolden Water waves effect
Moritz Voß Shadow effects
Lukas Degenar & Ingmar Kanitschneider Warping with Contourlines
Christoph Brzozowski Warping with B-Splines
Philip Claren & Christian Mühlhaupt Accumulationbuffer effects
Gabriel Zachmann
Last modified: Sat Sep 10 16:00:28 MDT 2005