3.8. DispWindow

Summary:

Window for SLM/LCD-Applications

Type:

DataIO

License:

LGPL

Platforms:

Windows, Linux

Devices:

OpenGL based widget to show cosine and graycode sequences

Author:

C. Kohler, ITO, University Stuttgart

3.8.1. Overview

This plugin opens a borderless window at a given position and displays horizontal or vertical cosine fringes including various graycode fringes (for unwrapping). The visualization is done with the help of OpenGL and the open source library GLEW.

For building this plugin, download (the binaries) of glew from http://glew.sourceforge.net/ and set the variable GLEW_DIR in CMake to the corresponding folder. The necessary library will finally be copied to the lib-folder of itom such that an entry in the environment variable path is not necessary. Please make sure, that you use always the same version of glew for all plugins that require this library.

3.8.2. Initialization

The following parameters are mandatory or optional for initializing an instance of this plugin:

  • x0: int, optional

    x0 position of window

    Value range: [-4096, 4096], Default: 0

  • y0: int, optional

    y0 position of window

    Value range: [-4096, 4096], Default: 0

  • xsize: int, optional

    height of window

    Value range: [3, 4096], Default: 3

  • ysize: int, optional

    width of window

    Value range: [3, 4096], Default: 3

  • period: int, optional

    cosine period in pixel

    Value range: [4:2:4096], Default: 12

  • phaseshift: int, optional

    number of total phase shifts

    Value range: [3, 8], Default: 4

  • lut: Sequence[int] (char), optional

    Lookup table for a gamma correction with 256 values. If given, the gamma correction will be enabled (default: off) and the projected values are then modified with lut[value].

  • dObj: itom.dataObject, optional

    DataObject with pixel values to display

3.8.3. Parameters

Every instance of this plugin has the following parameters:

color: int

0: Red, 1: Green, 2: Blue, 3: White

Value range: [0, 3], Default: 3

dObj: dataObject

DataObject with pixel values to display.

gamma: int

0: disable gamma correction, 1: enable gamma correction; default disable (see also ‘lut’)

Value range: [0, 1], Default: 0

lut: Sequence[int] (char)

Lookup table for a gamma correction with 256 values. The gamma correction itself is en-/disabled via parameter ‘gamma’. If enabled, the value to display is modified by lut[value]. Per default the lut is a 1:1 relation.

name: str, read-only

name of the plugin

numgraybits: int, read-only

Number of different images: Phaseshift + GrayCode + 2

Value range: [0, 80], Default: 5

numimg: int

Number of current image (phase images, dark image, bright image, graycode images)

Value range: [-1, 10], Default: 0

orientation: int

0: vertical, 1: horizontal; default: vertical

Value range: [0, 1], Default: 0

period: int

Cosine period in pixel. This must be a multiple of 2 and the number of ‘phaseshift’.

Value range: [4:2:4096], Default: 12

phaseshift: int

Count of phase shifts. If this value is changed and the ‘period’ does not fit to the new value, the ‘period’ is adapted to the next possible value.

Value range: [3, 8], Default: 4

x0: int

x0 position of display window [px]

Value range: [0, 1920], Default: 1820

xsize: int

width of window [px]

Value range: [3, 1920], Default: 100

y0: int

y0 position of display window [px]

Value range: [0, 1080], Default: 0

ysize: int

height of window [px]

Value range: [3, 1080], Default: 100

3.8.4. Gamma correction

If the parameter gamma is set to 0, no further gamma correction is enabled. This means, that the gray values of the cosine fringes are directly displayed as they are using a 8bit resolution:

screen_pixel = round(255 * [2*cos(alpha) + 1])

However, if your camera and projector has a non-linear behaviour between displayed and detected gray value, a gamma correction can and should be enabled. Then, the displayed gray value is:

screen_pixel = lut[round(255 * [2*cos(alpha) + 1])]

The lookup table (lut) consists of 256 values. In order to register the lookup table, you can project a uniform background with uniformly distributed gray-values (at least 64 different values) between 0 and full resolution (e.g. 255). The values should be sorted beginning with the darkest one until ‘white’:

for i in range(0,256,4):
    projector.exec("projectGrayValue", i)

Note

displaying any other image (graycode or cosine fringe) will clear the gray valued image

Then, record every uniform projection with the camera and determine the mean gray value. You then get a list of gray values, like the following one:

g = [25, 28, 32, 38, 50, 90, 92, 96, ... 198]

Call the exec function calcLut and pass g in order to let the plugin calculate the lut (based on a linear interpolation if g contains less values than 256):

projector.exec("calcLut", g)

Then, you need to enable the gamma correction:

projector.setParam("gamma", 1)

Finally, the lut (parameter lut) contains values, such that the recorded gray values applying the same uniformly distributed background images are linearly distributed.

3.8.5. Save current view to image file

Use the exec function grabFramebuffer to save the currently displayed view in the same size to an image file (the file type is determined by the file’s ending (file type must be supported by Qt’s QImage):

projector.exec("grabFramebuffer", "D:/test.pgm") #or
projector.exec("grabFramebuffer", "D:/test.jpg")