RunMat
GitHub

image — Display indexed or truecolor images as graphics objects with MATLAB image semantics and GPU-backed rendering paths.

image displays indexed or truecolor image data as a plotting object rather than as a detached bitmap. In RunMat it returns an image handle, uses the shared flattened surface/image-mode rendering path, and supports both host and GPU-backed truecolor or indexed-image workflows while preserving MATLAB image semantics around graphics-object behavior and axes placement.

How image works in RunMat

  • image(C) displays image data using implicit axes; image(X, Y, C) places the image explicitly on the target axes.
  • Indexed images and truecolor images both use the shared surface/image rendering architecture.
  • The returned value is an image-handle object that works with get and set.
  • image is object-oriented and placement-oriented; use imagesc when you specifically want scaled matrix visualization with color mapping semantics.
  • Dedicated GPU-backed paths cover both indexed and truecolor image inputs when plotting-compatible buffers are available.

How image runs on the GPU

Indexed images and truecolor images both have dedicated GPU-aware rendering paths in the image stack.

Image handle behavior, axes placement, and replay/export semantics remain aligned across GPU and fallback paths.

GPU memory and residency

image preserves GPU residency when the image pipeline can consume exported indexed or truecolor image buffers directly. If the active combination cannot stay on the direct path, RunMat gathers once and renders the same image-object semantics on the fallback path.

Examples

Display a simple indexed image

C = [1 2 3; 3 2 1; 2 3 1];
image(C);
colormap('jet');

Display a truecolor RGB image

img = zeros(100, 100, 3);
img(:,:,1) = 1;
img(25:75,25:75,2) = 1;
image(img);

Expected output:

% Displays a truecolor image object

Position an image explicitly on axes and inspect the handle

C = reshape(1:16, 4, 4);
h = image([0 3], [10 40], C);
get(h, 'Type')

Expected output:

ans =
    'image'

FAQ

How do I display RGB data with image?

Pass an MxNx3 array where the third dimension holds red, green, and blue channels. Values should be in [0, 1] for doubles or [0, 255] for uint8.

img = zeros(100, 100, 3);
img(:,:,1) = 1;           % full red
img(30:70, 30:70, 2) = 1; % green square
image(img);

When should I use image vs imagesc?

image displays pixel data as-is — either indexed colors through a colormap or direct RGB truecolor. imagesc automatically scales a 2-D matrix so its min and max span the full colormap range. If you're showing actual image pixels or pre-indexed data, use image. If you're visualizing a matrix of computed values as a heatmap, use imagesc.

Why does my image appear upside down?

By default, image sets the y-axis to go from top to bottom (row 1 at the top), which matches matrix indexing. If your coordinate system expects y to increase upward, call axis xy after image to flip the axis direction. Use axis ij to restore the default matrix-style orientation.

These functions work well alongside image. Each page has runnable examples you can try in the browser.

imagesc, colormap, colorbar, get, set

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how image works, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat for free

Open the sandbox and start running MATLAB code in seconds. No account required.