set_paint ( : : WindowHandle, Mode : )

Define the grayvalue output mode.

set_paint defines the output mode for grayvalue display (single- or multichannel) in the window. The mode is used by disp_image.

This page describes the different modes, that can be used for grayvalue output. It should be noted, that the mode 'default' is the most suitable.

The hardware characteristics determine how grayvalues can be displayed. On a screen with one to seven bit planes, only binary data can be displayed. On screens with at least eight bit planes, it is possible to display multiple grayvalues. For binary displays HALCON includes algorithms with dithering matrix (fast, but low resolution), minimal error (good, but slow) and thresholding. Using the thresholding algorithm, the threshold can be passed as a second parameter (a tuple with the string 'threshold' and the actual threshold, e.g.: ['theshold', 100]).

Displays with eight bit planes use approximately 200 grayvalues for output. Of course it is still possible to use a binary display on those displays.

A different way to display grayvalues is the histogram (mode: 'histogram'). This mode has two additional parameter values: Row (second value) and column (third value). They denote row and column of the histogram center for positioning on the screen. The scale factor (fourth value) determines the histogram size: a scale factor of 1 distinguishes 256 grayvalues, 2 distinguishes 128 grevalues, and so on. The four values are passed as a tuple, e.g. ['histogram', 256,256,1]. If only the first value is passed ('histogram'), the other values are set to defaults or the last values, respectively. For histogram computation see gray_histo. Histogram output honors the same parameters as procedures like disp_region etc. (e.g. set_color, set_draw, etc.)

Yet another mode is the display of relative frequencies of the number of connection components ("component_histogram"). For informations on computing the component histogram see shape_histo_all). Positioning and resolution are exactly as in the mode 'histogram'.

In mode 'mean', all object regions are displayed in their mean grayvalue.

The modes 'row' and 'column' allow the display of lines or columns, respecively. The position (line- and columnindex) is passed with the second paramter value. The third parameter value is the scale factor in percent (100 means 1 pixel per grayvalue, 50 means one pixel per two grayvalues).

Gray images can also be interpreted as 3d data, depending on the grayvalue. To view these 3d plots, select the modes 'contourline', '3D-plot' or '3D-plot_hidden'.

Two-channel images can be viewed as 'vectorfield'.

Three-channel images are interpreted as RGB images. They can be displayed in three different modes. Two of them can be optimized by Floyd-Steinberg dithering.

Paramters for modes that need more than one parameter can be passed the following ways:

- Only the name of the mode is passed: the defaults or the last
  values are used, respectively.
  Example: set_paint(::WindowHandle,'contourline':)
- All values are passed: all output characteristics can be set.
  Example: set_paint(::WindowHandle,['contourline',10,1]:)
- Only the first n values are passed: only the passed values are
  changed.
  Example: set_paint(::WindowHandle,['contourline',10]:)
- Some of the values are replaced by an asterisk ('*'): The value of
  the replaced parameters is not changed.
  Example: set_paint(::WindowHandle,['contourline','*',1]:)
If the current mode is 'default', HALCON chooses a suitable algorithm for the output of 2- and 3-channel images.. No set_paint call is necessary in this case.

Apart from set_paint there are other procedures that affect the output of grayvalues. The most important of them are set_part, set_part_style,set_lut and set_lut_style. Some output modes display grayvalues using region output (e.g. 'histogram','contourline','3D-plot', etc.). In these modes, paramters set with set_color, set_rgb,set_hsi, set_pixel, set_shape, set_line_width and set_insert influence grayvalue output. This can lead to unexpected results when using set_shape(::'convex':) and set_paint(::WindowHandle,'histogram':). Here the convex hull of the histogram is displayed.

Modes:

one-channel images

  'default'
                    optimal display on given hardware
  'gray'
                    grayvalue output
  'mean'
                    mean grayvalue
  'dither4_1'
                    binary image, dithering matrix 4x4
  'dither4_2'
                    binary image, dithering matrix 4x4
  'dither4_3'
                    binary image, dithering matrix 4x4
  'dither8_1'
                    binary image, dithering matrix 8x8
  'floyd_steinberg'
                    binary image, optimal grayvalue simulation
  'threshold'
                    binary image, threshold: 128 (default)

  ['threshold',Threshold]
  ['threshold',200] 
                    binary image, any threshold: (here: 200)
  'histogram'
                    grayvalue output as histogram
                    position default: max. size, in the window center
  ['histogram',Row,Column,Scale]
  ['histogram',256,256,2]              
                    grayvalue output as histogram, any parameter values
                    positioning: window center (here (256,256))
                    size: (here 2, half the max. size)
  'component_histogram'
                    output as histogram of the connection components.
                    Positioning: default
  ['component_histogram',Row,Column,Scale]
  ['component_histogram',256,256,1]
                    output as histogram of the connection components.
                    Positioning: (here (256, 256))
                    Scaling: (here 1, max. size)
  'row'
                    output of the grayvalue profile along the given
                    line.
                    line: image center (default)
                    Scaling: 50%
  ['row',Row,Scale]
  ['row',100,20]   
                    output of the grayvalue profile of line 100 with
                    a scaling of 0.2 (20%).
  'column'
                    output of the grayvalue profile along the given
                    column.
                    column: image center (default)
                    Scaling: 50%
  ['column',Column,Scale]
  ['column',100,20]
                    output of the grayvalue profile of column 100 with
                    a scaling of 0.2 (20%).
  'contourline'
                    grayvalue output as contour lines:
                    the grayvalue difference per line is defined
                    with the parameter 'Step' (default: 30,
                    i.e. max. 8 lines for 256 grayvalues). The line
                    can be displayed in a given color (see
                    set_color) or in the grayvalue they
                    represent. This behaviour is defined with the
                    parameter 'Colored' (0 = color, 1 = grayvalues).
                    Default is color.
  ['contourline',Step,Colored]
  ['contourline',15,1]
                    grayvalue output as contour lines with a step of
                    15 and gray output.
  '3D-plot'
                    grayvalues are interpreted as 3d data: the
                    greater the value, the 'higher' the assumed
                    mountain. Lines with step 2 (second paramter
                    value) are drawn along the x- and y-axes.
                    The third parameter (Colored) determines, if the
                    output should be in color (default) or
                    grayvalues. To define the projection of the 3d
                    data, use the parameters EyeHeight and
                    EyeDistance. The projection parameters take
                    values from 0 to 255. ScaleGray defines a
                    factor, by which the grayvalues are multiplied
                    for 'height' interpretation (given in
                    percent. 100\% = factor 1). For extreme values of
                    EyeHeight and EyeDistance the image can be
                    shifted out of place. Use RowPos and ColumnPos
                    to move the whole output. Values from -127 to
                    127 are possible.
  ['3D-plot',Step,Colored,EyeHeight,EyeDistance,ScaleGray,RowPos,ColumnPos]
  ['3D-plot',5,1,110,160,150,70,-10]
                    line step:   5 pixel
                    Colored:     yes (1)
                    EyeHeight:   110
                    EyeDistance: 160
                    ScaleGray:   1.5 (150)
                    RowPos:      70 pixel down
                    ColumnPos:   10 pixel right
  '3D-plot_hidden'  
                    like '3D-plot', but computes hidden lines.
  ['3D-plot_hidden',Step,Colored,EyeHeight,EyeDistance,ScaleGray,RowPos,
   ColumnPos] 

Two-channel images:

  'default'
                    output as vector field.
  'vectorfield'
                    output of the two channels as displacement
                    vector field. Procedures like optical_flow*
                    produce images of pixel displacements (first
                    channel: x-displacement, second channel:
                    y-displacement).
                    In this mode, an arrow is drawn for each
                    vector. The parameter Step has to be set in
                    correspondence to optical_flow*. Short vectors
                    can be suppressed by the third parameter value
                    (MinLength). The fourth parameter value scales
                    the vector length. Vectors, that exceed the
                    window boundaries are nor drawn.
  ['vectorfield',Step,MinLengh,ScaleLength]                 
  ['vectorfield',16,2,3]
                    Output of every 16. vector, that is longer than 2
                    pixel. Each vector is multiplied by 3 for
                    output.

Three-channel images:

  'default'
                    output as RGB image with 'median_cut'.
  'television'
                    color addition algorithm for RGB images: (three
                    components necessary for
                    disp_image). Images are displayed
                    via a fixed color lookup table. Fast, but
                    non-optimal color resolution. Only recommended on
                    bright screens.
  'grid_scan'
                    grid-scan algorithm for RGB images (three
                    components necessary for
                    disp_image). An optimized  color
                    lookup table is generated for each image. Slower
                    than 'television'. Disadvantages: Hard color
                    boundaries (no dithering). Different color lookup
                    table for every image.
  'grid_scan_floyd_steinberg'
                    grid-scan with Floyd-Steinberg dithering for
                    smooth color boundaries.
  'median_cut'
                    median-cut algorithm for RGB images (three
                    components necessary for
                    disp_image). Similar to grid-scan.
                    Disadvantages: Hard color boundaries (no
                    dithering). Different color lookup table for
                    every image.
  'median_cut_floyd_steinberg'
                    median-cut algorithm with Floyd-Steinberg
                    dithering for smooth color boundaries.


Attention

- Display of color images ('television', 'grid_scan', etc.) changes
  the color lookup tables.
- If a wrong color mode is set, the error message may appear not until
  the disp_image call.
- Grayvalue output may be influenced by region output parameters. This
  can yield unexpected results.


Parameters

WindowHandle (input_control)
window -> integer
Window_id.

Mode (input_control)
string-array -> string / integer
Output mode. Additional parameters possible.
Default value: 'default'
List of values: ''default'', ''histogram'', ''row'', ''column'', ''contourline'', ''3D-plot'', ''3D-plot_hidden'', ''3D-plot_point''


Example
read_image(Image,'fabrik') 
open_window(0,0,-1,-1,'root','visible',"',WindowHandle) 
query_paint(WindowHandleModi) 
fwrite_string(['available gray value modes: ',Modi]) 
fnew_line() 
disp_image(Image,WindowHandle)  
get_mbutton(WindowHandle,_,_,_) 
set_color(WindowHandle,'red') 
set_draw(WindowHandle,'margin') 
set_paint(WindowHandle,'histogram') 
disp_image(Image,WindowHandle)  
set_color(WindowHandle,'blue') 
set_paint(WindowHandle,['histogram',100,100,3]) 
disp_image(Image,WindowHandle)  
set_color(WindowHandle,'yellow') 
set_paint(WindowHandle,['row',100]) 
disp_image(Image,WindowHandle)  
get_mbutton(WindowHandle,_,_,_) 
clear_window(WindowHandle) 
set_paint(WindowHandle,['contourline',10,1]) 
disp_image(Image,WindowHandle)  
set_lut(WindowHandle,'color') 
get_mbutton(WindowHandle,_,_,_) 
clear_window(WindowHandle) 
set_part(WindowHandle,100,100,300,300) 
set_paint(WindowHandle,'3D-plot') 
disp_image(Image,WindowHandle).

Result

set_paint returns 2 (H_MSG_TRUE) if the parameter is correct and the window is valid. Otherwise an exception handling is raised.


Parallelization Information

set_paint is reentrant, local, and processed without parallelization.


Possible Predecessors

query_paint, get_paint


Possible Successors

disp_image


See also

get_paint, query_paint, disp_image, set_shape, set_rgb, set_color, set_gray


Module

Foundation



Copyright © 1996-2008 MVTec Software GmbH