Unable to create custom colormap from RGB data?
Show older comments
Still bogged down in the difference between an array and a matrix...
Everything was working well until I stumbled upon the following error message, at the time of attempting to create the colormap :
Colormap must be an Mx3 array of type single or double with values in the range [0,1] or an Mx3
array of type uint8.
Here's my code :
% Generate three vectors
Axe_A_B = transpose(linspace(-128, 128, 21));
Axe_La = transpose(linspace(39, 50, 21));
Axe_Lb = transpose(linspace(15,100, 21));
Lab_Axe_AB = [Axe_La, Axe_A_B, Axe_A_B]; % 21 x 3 double
RGB_Axe_AB = lab2rgb(Lab_Axe_AB)
% negatives values?
[row,col] = size(RGB_Axe_AB);
for ROW = 1:row
if RGB_Axe_AB(ROW,1) < 0
RGB_Axe_AB(ROW,1) = 0;
end
if RGB_Axe_AB(ROW,2) < 0
RGB_Axe_AB(ROW,2) = 0;
end
if RGB_Axe_AB(ROW,3) < 0
RGB_Axe_AB(ROW,3) = 0;
end
end
RGB_Axe_AB_ColorMap = colormap(RGB_Axe_AB)
I'm going in circle...
Documentation states :
% Colormap must have 3 columns: [R,G,B]
% defining a three-column matrix of values
Here's the content of my RGB_Axe_AB 'variable' :
RGB_Axe_AB =
0 0.5400 1.2184
0 0.5321 1.1330
0 0.5240 1.0486
0 0.5152 0.9653
0 0.5058 0.8831
0 0.4952 0.8020
0 0.4833 0.7220
0 0.4695 0.6432
0 0.4536 0.5654
0.2388 0.4349 0.4886
0.4126 0.4126 0.4126
0.5271 0.3857 0.3369
0.6198 0.3526 0.2607
0.7011 0.3106 0.1812
0.7756 0.2540 0.0886
0.8459 0.1660 0
0.9139 0 0
0.9810 0 0
1.0478 0 0
1.1142 0 0
1.1804 0 0
I did not bother to create a 256 size variable at this point. ...
Accepted Answer
More Answers (0)
Categories
Find more on Display Image 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!



