Apply 4 color 2d colormap to data

2 Ansichten (letzte 30 Tage)
Elin Jacobs
Elin Jacobs am 9 Dez. 2022
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);

Antworten (0)

Kategorien

Find more on Colormaps in Help Center and File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by