rgbofall

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

return all different methods of matlab into a rgb set as type double



See Also: rgb2char , char2rgb , rgb2bgr16

Example Illustration

 missing image of rgbofall(x)

Syntax

rgb=rgbofall(x)

Input Parameter

x: input character 'b' or [255 0 0] etc.

Output Parameter

rgb: rgb value between 0 and 1

Examples


rgbofall('y')
rgbofall(['y','g'])
rgbofall([255 0 64])




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, rgbofall, is designed to convert various input formats into RGB color values represented as doubles between 0 and 1. The function can handle character inputs, numeric arrays, and other formats, converting them into a standardized RGB format.

Input Parameters

Output

Algorithm Steps

  1. Initialize a color table ctab with the characters 'kbgcrmyw', representing black, blue, green, cyan, red, magenta, yellow, and white.
  2. Check if the input x is a character array:
    • Determine the number of characters nc in x.
    • Initialize an nc by 3 matrix rgb with NaN values.
    • For each character in x, convert it to an RGB value using the char2rgb function and store it in the rgb matrix.
    • Normalize the rgb values by dividing by 255.
  3. If x is a numeric array with three columns and any value greater than 1:
    • Normalize the array by dividing by 255 to convert it to a range between 0 and 1.
  4. If x is a numeric array with three columns and all values are less than or equal to 1:
    • Return the array as is, assuming it is already in the correct range.
  5. If x is a single row or column vector:
    • Determine the number of elements nc in x.
    • Initialize an nc by 3 matrix rgb with NaN values.
    • For each element in x, map it to a character in ctab and convert it to an RGB value using char2rgb.
    • Normalize the rgb values by dividing by 255.
  6. If none of the above conditions are met, assume x is already in the correct RGB format and return it as is.
Algorithm explaination created using ChatGPT on 2025-08-19 00:19. (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