RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • gray2rgb
    • hsv2rgb
    • im2double
    • im2uint16
    • im2uint8
    • ind2rgb
    • lab2rgb
    • rgb2gray
    • rgb2hsv
    • rgb2lab

rgb2lab — Convert RGB image, image-stack, or colormap values to CIE L*a*b*.

rgb2lab(RGB) converts RGB values to CIE L*a*b*. ColorSpace and WhitePoint name-value pairs select source primaries and reference white.

Syntax

LAB = rgb2lab(RGB, Name=Value)

Inputs

RGB
Type
Any
Required
Yes
Description
RGB image, image stack, or c-by-3 colormap values.
NameValue
Type
Any
Required
Variadic
Description
ColorSpace or WhitePoint name-value options.
NameTypeRequiredDefaultDescription
RGBAnyYes—RGB image, image stack, or c-by-3 colormap values.
NameValueAnyVariadic—ColorSpace or WhitePoint name-value options.

Returns

LAB
Type
NumericArray
Description
CIE L*a*b* image or colormap converted from RGB input.
NameTypeDescription
LABNumericArrayCIE L*a*b* image or colormap converted from RGB input.

Errors

RunMat:rgb2lab:TooManyOutputs
When
More than one output argument is requested.
Message
rgb2lab: too many output arguments
RunMat:rgb2lab:TooManyInputs
When
More than the two supported name-value pairs are supplied.
Message
rgb2lab: too many input arguments
RunMat:rgb2lab:InvalidInput
When
Input cannot be interpreted as an MxNx3 RGB image or Nx3 RGB colormap.
Message
rgb2lab: invalid input
IdentifierWhenMessage
RunMat:rgb2lab:TooManyOutputsMore than one output argument is requested.rgb2lab: too many output arguments
RunMat:rgb2lab:TooManyInputsMore than the two supported name-value pairs are supplied.rgb2lab: too many input arguments
RunMat:rgb2lab:InvalidInputInput cannot be interpreted as an MxNx3 RGB image or Nx3 RGB colormap.rgb2lab: invalid input
RunMat:rgb2lab:InternalL*a*b* output tensor construction fails internally.rgb2lab: internal conversion failure
RunMat:rgb2lab:InvalidOptionA ColorSpace or WhitePoint name-value argument is malformed or unsupported.rgb2lab: invalid name-value option

Classes and geometry

RGB accepts nonempty M-by-N-by-3 truecolor images, M-by-N-by-3-by-P stacks, and nonempty K-by-3 colormaps in single, double, uint8, or uint16. An image stack may have an empty trailing stack axis while M and N remain positive. Logical, complex, signed and wide unsigned integers, and other geometry reject.

uint8 and uint16 samples normalize by their full native range; floating samples clamp to [0,1]. Single input produces single Lab; double and integer input produce double. Shape is preserved, including stack axes.

Color controls

ColorSpace accepts case-insensitive srgb (default), adobe-rgb-1998, prophoto-rgb, or linear-rgb. WhitePoint accepts A, C, E, D50, D55, D65 (default), ICC, or a finite positive single/double 1-by-3 XYZ row. Up to two name-value pairs are accepted; repeated options use the last value.

Execution and compatibility

The channel-coupled host conversion is a fusion boundary. Parsed controls and admitted class, shape, and owner precede operand preparation. Resident output restores through the original owner when possible. Explicit gpuArray input requires the RunMat-only Rgb2labExplicitGpuExtension; automatic resident input may gather normally.

Examples

Convert RGB white to Lab

RGB = reshape([1 1 1],[1 1 3]); LAB = rgb2lab(RGB); size(LAB)

Expected output:

ans = [1 1 3]

Select a reference white

LAB = rgb2lab([1 0 0],'ColorSpace','srgb','WhitePoint','D50'); size(LAB)

Expected output:

ans = [1 3]

Using rgb2lab with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how rgb2lab changes the result.

Run a small rgb2lab example, explain the result, then change one input and compare the output.

Related Image functions

Color

gray2rgb · hsv2rgb · im2double · im2uint16 · im2uint8 · ind2rgb · lab2rgb · rgb2gray · rgb2hsv

Filters

filter2 · fspecial · imfilter

Io

imfinfo · imread · imwrite

Image

imhist

Source you can read

Every RunMat function's source is public. Read exactly how rgb2lab is executed, line by line, in Rust.

  • View the source for rgb2lab in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Classes and geometry
  • Color controls
  • Execution and compatibility
  • Examples
  • Convert RGB white to Lab
  • Select a reference white
  • Using rgb2lab with coding agents
  • Related Image functions
  • Color
  • Filters
  • Io
  • Image
  • Source you can read
  • About RunMat