im2double — Convert images to double precision in MATLAB and RunMat.
im2double(I) converts image data to double precision. Integer image classes are scaled to [0, 1], following MATLAB semantics.
Syntax
J = im2double(I)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
I | Any | Yes | — | Image data to convert. |
Returns
| Name | Type | Description |
|---|---|---|
J | NumericArray | Converted image data in double precision. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:im2double:TooManyInputs | More than one input argument is supplied. | im2double: too many input arguments |
RunMat:im2double:InvalidInput | Input cannot be gathered or interpreted for image conversion. | im2double: invalid input |
RunMat:im2double:UnsupportedInputType | Input type is outside supported numeric/logical image classes. | im2double: unsupported input type |
RunMat:im2double:Internal | Internal conversion step fails while building output tensor. | im2double: internal conversion failure |
How im2double works
- uint8 and uint16 tensors are scaled into [0,1].
- Floating-point tensors keep their numeric values and become double host tensors.
- Logical images convert to 0 and 1.
Example
Convert Read Image
I = im2double(imread("photo.png"));Expected output:
% I is double image data in [0,1] for integer inputsUsing im2double with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how im2double changes the result.
Run a small im2double example, explain the result, then change one input and compare the output.
Related Image functions
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how im2double is executed, line by line, in Rust.
- View the source for im2double in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 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.