Clear Filters
Clear Filters

How to change 257x251x1 uint8 into 257x251x3 uint8?

6 views (last 30 days)
Can anyone help me out? How to change my input image data in grayscale 257x251x1 uint8 change into 'truecolor' rgb type? (mxnx3)
Here my codes:
The error occured; Index in position 3 exceeds array bounds (must not exceed 1).

Accepted Answer

Walter Roberson
Walter Roberson on 13 Jun 2023
if ndims(I) == 2; I = I(:,:,[1 1 1]); end %convert to rgb
Walter Roberson
Walter Roberson on 13 Jun 2023
Based on the sizes it looks like you concatenated along the first dimension when you needed to concatenate along the 4th dimension.
mohd akmal masud
mohd akmal masud on 13 Jul 2023
Dear @Dayangku Nur Faizah Pengiran Mohamad, maybe you can attached the image data, and groundtruth labeling here.
quite imposiible to find the error just read the code given.

Sign in to comment.

More Answers (0)


Find more on Just for fun in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!