Apply 4 color 2d colormap to data
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have two 1800x3600 matrices with values between 0-1, and have generated a four-color 2d colormap with the below code, where the x axis would correspond to the values in one matrix and y axis would correspond to the values in the other. I want to use the scheme to colorcode each element with the same index in the two matrices, simlar to the attached figure. Any pointers to accomplish this would be appreciated!
c{1} = [1 0 0]; % specify 4 colors
c{2} = [0 0 0];
c{3} = [1 0 1];
c{4} = [0 0 1];
C = reshape(vertcat(c{:}), 2, 2, []);
n = 700; % number of pixels
img = zeros(n, n, 3);
for i=1:3
img(:,:,i) = interp2([0 1], [0 1], C(:,:,i), linspace(0,1,n), linspace(0,1,n).');
end
imshow(img);

0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Find more on Colormaps 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!