How to convert uint8 to rgb image in MATLAB r2018b?

23 visualizzazioni (ultimi 30 giorni)
I have a 365x466x3 uint8 matrix and I need to convert it into RGB model. when I used the command "ind2rgb" i am getting the following problem, "Unable to perform assignment because the size of the left side is 365-by-466 and the size of the right side is 365-by-466-by-3." Any solution?? Thanks in advance.

Risposta accettata

Walter Roberson
Walter Roberson il 24 Apr 2019
365 x 466 x 3 is already RGB, unless it is HSV or L*a*b* or similar.
If you had a 365 x 466 indexed image and a colormap then you could use ind2rgb() to convert it to RGB, but you would typically assign the result to an entire variable rather than to a portion of a variable. But it could be done, such as
for K = 1 : length(filenames)
[ind, cmap] = imread( filenames{K} );
all_images(:,:,:,K) = ind2rgb(ind, cmap);
end

Più risposte (0)

Categorie

Scopri di più su Modify Image Colors in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by