rgb2char

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Visualization
Introduced first in SolidGeometry 4.4, Creation date: 2018-11-26, Last change: 2025-09-14

returns a color character from an RGB value

Description

SG-Lib 4.5 supports list of colors

See Also: char2rgb , rgb2bgr16

Example Illustration

 missing image of rgb2char(RGB)

Syntax

c=rgb2char(RGB)

Input Parameter

RGB: [R G B] color

Output Parameter

c: color character

Examples


rgb2char([255 255 0])
rgb2char(char2rgb('krgbw'))




Copyright 2018-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, rgb2char, converts RGB color values into a single character representing a color. It is part of the SG-Library and was introduced in SolidGeometry 4.4.

Input Parameters

Output Results

Algorithm Steps

  1. Determine the number of colors, nc, by checking the number of rows in the RGBA matrix.
  2. Define a string colbar containing the characters 'kbgcrmyw', which represent the colors black, blue, green, cyan, red, magenta, yellow, and white, respectively.
  3. Initialize the output string ci with spaces, having the same length as the number of colors, nc.
  4. Iterate over each row in the RGBA matrix:

The function does not produce any graphical output unless the commented-out section is activated, which would create a 3D plot with lighting effects.

Algorithm explaination created using ChatGPT on 2025-08-18 23:12. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21