set_lutT_set_lutSetLutSetLutset_lut (Operator)

Name

set_lutT_set_lutSetLutSetLutset_lut — Set “look-up-table” (lut).

Signature

set_lut( : : WindowHandle, LookUpTable : )

Herror T_set_lut(const Htuple WindowHandle, const Htuple LookUpTable)

void SetLut(const HTuple& WindowHandle, const HTuple& LookUpTable)

void HWindow::SetLut(const HTuple& LookUpTable) const

void HWindow::SetLut(const HString& LookUpTable) const

void HWindow::SetLut(const char* LookUpTable) const

void HWindow::SetLut(const wchar_t* LookUpTable) const   ( Windows only)

static void HOperatorSet.SetLut(HTuple windowHandle, HTuple lookUpTable)

void HWindow.SetLut(HTuple lookUpTable)

void HWindow.SetLut(string lookUpTable)

def set_lut(window_handle: HHandle, look_up_table: MaybeSequence[Union[int, float, str]]) -> None

Description

set_lutset_lutSetLutSetLutset_lut sets look-up-table of the device (monitor) displaying the output window. A look-up-table defines the transformation of a “gray value” within an image into a gray value or color on the screen. It describes the screen gray value/color as a combination of red, green and blue for any image gray value (0..255) (so it is a 'table' to 'look up' the screen gray value/color for each image gray value: look-up-table). Transformation into screen-colors is performed in real-time at every time the screen is displayed new (typically this happens about 60 - 70 times per second). So it is possible to change the look-up-table to get a new look of images or regions. Please remind that not all machines support changing the look-up-table (e.g., monochrome resp. real color).

Look-up-tables within HALCON (and on a machine that supports 256 colors) are divided into three areas:

S:

system area resp. user area,

G:

graphic colors,

B:

image data.

Colors in S descend from applications that were active before starting HALCON and should not get lost. Graphic colors in G are used for operators such as disp_regiondisp_regionDispRegionDispRegiondisp_region, disp_circledisp_circleDispCircleDispCircledisp_circle etc. and are set unique within all look-up-tables. An output in a graphic color has always got the same (color-)look, even if different look-up-tables are used. set_colorset_colorSetColorSetColorset_color and set_rgbset_rgbSetRgbSetRgbset_rgb set graphic colors. Gray values resp. colors in B are used by disp_imagedisp_imageDispImageDispImagedisp_image to display an image. They can change according to the current look-up-table. There exist two exceptions to this concept:

For common monitors only one look-up-table can be loaded per screen. Whereas set_lutset_lutSetLutSetLutset_lut can be activated separately for each window. There is the following solution for this problem: It will always be activated the look-up-table that is assigned to the “active window” (a window is set into the state “active” by the window manager).

look-up-table can also be used with true-color displays. In this case the look-up-table will be simulated in software. This means, that the look-up-table will be used each time an image is displayed.

query_lutquery_lutQueryLutQueryLutquery_lut lists the names of all look-up-tables. They differ from each other in the area used for gray values. Within this area the following behavior is defined:

Gray value tables (1-7 image levels)

Value Description
'default'"default""default""default""default" Only the two basic colors (generally black and white) are used.
Color tables (real color, static gray value steps)

Value Description
'default'"default""default""default""default" Table proposed by the hardware.
Gray value tables (256 colors)

Value Description
'default'"default""default""default""default" As 'linear'"linear""linear""linear""linear".
'linear'"linear""linear""linear""linear" Linear increasing of gray values from 0 (black) to 255 (white).
'inverse'"inverse""inverse""inverse""inverse" Inverse function of 'linear'"linear""linear""linear""linear".
'sqr'"sqr""sqr""sqr""sqr" Gray values increase according to square function.
'inv_sqr'"inv_sqr""inv_sqr""inv_sqr""inv_sqr" Inverse function of 'sqr'"sqr""sqr""sqr""sqr".
'cube'"cube""cube""cube""cube" Gray values increase according to cubic function.
'inv_cube'"inv_cube""inv_cube""inv_cube""inv_cube" Inverse function of 'cube'"cube""cube""cube""cube".
'sqrt'"sqrt""sqrt""sqrt""sqrt" Gray values increase according to square-root function.
'inv_sqrt'"inv_sqrt""inv_sqrt""inv_sqrt""inv_sqrt" Inverse Function of 'sqrt'"sqrt""sqrt""sqrt""sqrt".
'cubic_root'"cubic_root""cubic_root""cubic_root""cubic_root" Gray values increase according to cubic-root function.
'inv_cubic_root'"inv_cubic_root""inv_cubic_root""inv_cubic_root""inv_cubic_root" Inverse Function of 'cubic_root'"cubic_root""cubic_root""cubic_root""cubic_root".
Color tables (256 colors)

Value Description
'color1'"color1""color1""color1""color1" Linear transition from red via green to blue.
'color2'"color2""color2""color2""color2" Smooth transition from yellow via red, blue to green.
'color3'"color3""color3""color3""color3" Smooth transition from yellow via red, blue, green, red to blue.
'color4'"color4""color4""color4""color4" Smooth transition from yellow via red to blue.
'three'"three""three""three""three" Displaying the three colors red, green and blue.
'six'"six""six""six""six" Displaying the six basic colors yellow, red, magenta, blue, cyan and green.
'twelve'"twelve""twelve""twelve""twelve" Displaying 12 colors.
'twenty_four'"twenty_four""twenty_four""twenty_four""twenty_four" Displaying 24 colors.
'rainbow'"rainbow""rainbow""rainbow""rainbow" Displaying the spectral colors from red via green to blue.
'temperature'"temperature""temperature""temperature""temperature" Temperature table from black via red, yellow to white.
'change1'"change1""change1""change1""change1" Color changes after every pixel within the table alternating the six basic colors.
'change2'"change2""change2""change2""change2" Fivefold color changes from green via red to blue.
'change3'"change3""change3""change3""change3" Threefold color changes from green via red to blue.
'jet'"jet""jet""jet""jet" Smooth transition from blue via green, yellow to red.
'inverse_jet'"inverse_jet""inverse_jet""inverse_jet""inverse_jet" Smooth transition from red via yellow, green to blue.
'batlow'"batlow""batlow""batlow""batlow" Perceptually uniform and color-vision-deficiency friendly.
'inverse_batlow'"inverse_batlow""inverse_batlow""inverse_batlow""inverse_batlow" Perceptually uniform and color-vision-deficiency friendly.

The look-up-table LookUpTableLookUpTableLookUpTablelookUpTablelook_up_table to be used in WindowHandleWindowHandleWindowHandlewindowHandlewindow_handle can be set in the following ways:

Name of the look-up-table

Select the look-up-table by setting its name (see query_lutquery_lutQueryLutQueryLutquery_lut).

File name of look-up-table

Read a look-up-table from a file. Every line of such a file must contain three numbers in the range of 0 to 255, with the first number describing the amount of red, the second the amount of green and the third the amount of blue of the represented display color. The number of lines can vary. The first line contains information for the first gray value and the last line for the last value. If there are less lines than gray values, the available information values are distributed over the whole interval. If there are more lines than gray values, a number of (uniformly distributed) lines is ignored. The file-name must conform to ”LookUpTable.lut”. Within the parameter the name is specified without file extension. HALCON will search for the file in the current directory and after that in a specified directory (see 'lut_dir'"lut_dir""lut_dir""lut_dir""lut_dir" in set_systemset_systemSetSystemSetSystemset_system).

Tuple

Set RGB values directly as a tuple. The number of parameter values must conform to the number of pixels currently used within the look-up-table.

Any of the above combined with custom value range

Set a custom value range to be mapped by the look-up-table. By default, HALCON uses the minimum and maximum gray values and of an image (except byte images) and maps these values to 0 and 255 when applying the look-up-table. It is possible to override this behavior by passing a tuple to set_lutset_lutSetLutSetLutset_lut in the form [LUT, g_min, g_max] (where 'LUT'"LUT""LUT""LUT""LUT" is any of the options above). This feature can be particularly useful when dealing with outliers in a real image.

The default behavior is reset by using one of the options above without minimum and maximum gray values.

Attention

set_lutset_lutSetLutSetLutset_lut can only be used with monitors supporting 256 gray levels/colors.

Execution Information

Parameters

WindowHandleWindowHandleWindowHandlewindowHandlewindow_handle (input_control)  window HWindow, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Window handle.

LookUpTableLookUpTableLookUpTablelookUpTablelook_up_table (input_control)  filename.read(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

Name of look-up-table, values of look-up-table (RGB) or file name.

Default: 'default' "default" "default" "default" "default"

Suggested values: 'default'"default""default""default""default", 'linear'"linear""linear""linear""linear", 'inverse'"inverse""inverse""inverse""inverse", 'sqr'"sqr""sqr""sqr""sqr", 'inv_sqr'"inv_sqr""inv_sqr""inv_sqr""inv_sqr", 'cube'"cube""cube""cube""cube", 'inv_cube'"inv_cube""inv_cube""inv_cube""inv_cube", 'sqrt'"sqrt""sqrt""sqrt""sqrt", 'inv_sqrt'"inv_sqrt""inv_sqrt""inv_sqrt""inv_sqrt", 'cubic_root'"cubic_root""cubic_root""cubic_root""cubic_root", 'inv_cubic_root'"inv_cubic_root""inv_cubic_root""inv_cubic_root""inv_cubic_root", 'color1'"color1""color1""color1""color1", 'color2'"color2""color2""color2""color2", 'color3'"color3""color3""color3""color3", 'color4'"color4""color4""color4""color4", 'three'"three""three""three""three", 'six'"six""six""six""six", 'twelve'"twelve""twelve""twelve""twelve", 'twenty_four'"twenty_four""twenty_four""twenty_four""twenty_four", 'rainbow'"rainbow""rainbow""rainbow""rainbow", 'temperature'"temperature""temperature""temperature""temperature", 'cyclic_gray'"cyclic_gray""cyclic_gray""cyclic_gray""cyclic_gray", 'cyclic_temperature'"cyclic_temperature""cyclic_temperature""cyclic_temperature""cyclic_temperature", 'hsi'"hsi""hsi""hsi""hsi", 'change1'"change1""change1""change1""change1", 'change2'"change2""change2""change2""change2", 'change3'"change3""change3""change3""change3", 'jet'"jet""jet""jet""jet", 'inverse_jet'"inverse_jet""inverse_jet""inverse_jet""inverse_jet", 'batlow'"batlow""batlow""batlow""batlow", 'inverse_batlow'"inverse_batlow""inverse_batlow""inverse_batlow""inverse_batlow"

File extension: .lut

Example (HDevelop)

read_image(Image,'monkey')
query_lut(WindowHandle,LUTs)
for i := 0 to |LUTs|-1 by 1
  set_lut(WindowHandle,LUTs[i])
  fwrite_string(FileHandle, ['current table ',LUTs[i]])
  fnew_line(FileHandle)
  get_mbutton(WindowHandle,_,_,_)
endfor

Example (C)

Htuple WindowHandleTuple, LUTs;
read_image(&Image,"monkey");
create_tuple(&WindowHandleTuple,1);
set_i(WindowHandleTuple,WindowHandle,0);
T_query_lut(WindowHandleTuple,&LUTs) \:
for(i=0; i<length_tuple(LUTs)-1; i++)
{
  set_lut(WindowHandle,get_s(LUTs,i));
  fwrite_string(FileHandle,"current table: ");
  fwrite_string(FileHandle,get_s(LUTs,i));
  fnew_line(FileHandle);
  get_mbutton(WindowHandle,NULL,NULL,NULL);
};

Example (HDevelop)

read_image(Image,'monkey')
query_lut(WindowHandle,LUTs)
for i := 0 to |LUTs|-1 by 1
  set_lut(WindowHandle,LUTs[i])
  fwrite_string(FileHandle, ['current table ',LUTs[i]])
  fnew_line(FileHandle)
  get_mbutton(WindowHandle,_,_,_)
endfor

Example (HDevelop)

read_image(Image,'monkey')
query_lut(WindowHandle,LUTs)
for i := 0 to |LUTs|-1 by 1
  set_lut(WindowHandle,LUTs[i])
  fwrite_string(FileHandle, ['current table ',LUTs[i]])
  fnew_line(FileHandle)
  get_mbutton(WindowHandle,_,_,_)
endfor

Result

set_lutset_lutSetLutSetLutset_lut returns 2 ( H_MSG_TRUE) if the hardware supports a look-up-table and the parameter is correct. Otherwise an exception is raised.

Possible Predecessors

query_lutquery_lutQueryLutQueryLutquery_lut, get_lutget_lutGetLutGetLutget_lut

See also

get_lutget_lutGetLutGetLutget_lut, query_lutquery_lutQueryLutQueryLutquery_lut, set_colorset_colorSetColorSetColorset_color, set_rgbset_rgbSetRgbSetRgbset_rgb, set_hsiset_hsiSetHsiSetHsiset_hsi, write_lutwrite_lutWriteLutWriteLutwrite_lut

Module

Foundation