Colormap setting the colors i want
Mostra commenti meno recenti
Hello, So I discovered Colormap, and I want to draw a Color map of a matrix A I got that has ranges from 0 to 1. But I don't want to use the colours Matlab provides (jet for example), I want to create my own. Green for 0, Red for 1, and in between a mix from red, yellow for 0.5, orange and then red. A bit like Excel does.
colormap('jet');
imagesc(A);
colorbar;
Thanks
2 Commenti
Stephen23
il 29 Giu 2018
"But I don't want to use the colours Matlab provides..."
As well as the ones that MATLAB provides:
you can find plenty of colormaps on FEX:
Tiago Dias
il 29 Giu 2018
Risposta accettata
Più risposte (2)
Image Analyst
il 29 Giu 2018
Create your own colormap then assign values in whatever way you want:
numColors = 256; % Whatever....
myColorMap = zeros(numColors, 3); % Col1 = red, col2 = green, col3 = blue.
myColorMap(row1:row2, 1); % Set red values however you want.
... etc...
% Apply it.
colormap(handlesToMyAxes, myColorMap);
% Show bar
colorbar;
9 Commenti
Tiago Dias
il 29 Giu 2018
Image Analyst
il 29 Giu 2018
You probably did not assign row1. You need to do that. Basically a colormap is an N by 3 array where each row corresponds to the value of your image, and contains the RGB values that you want that value of your image to appear in. So for example if row 1 is [0, 1, 0.5] then that would mean gray level 0 (which row 1 corresponds to) should show up with no red, full brightness green, and half brightness blue.
If you're not familiar with programming then you might just use the color map editor like Stephen referred you to.
Tiago Dias
il 29 Giu 2018
Stephen23
il 29 Giu 2018
"Do I need to also select the intermediate colors? or Matlab does an "color interpolation" from the start color to the end color?"
If you want a 64x3 colormap (the default size) then you will need to define all 64 colors yourself (e.g. by interpolation).
Tiago Dias
il 29 Giu 2018
Tiago Dias
il 29 Giu 2018
Image Analyst
il 29 Giu 2018
Please attach your matrix "A" in a .mat file.
Tiago Dias
il 2 Lug 2018
Wooshik Kim
il 29 Giu 2018
Modificato: Wooshik Kim
il 29 Giu 2018
0 voti
You can set your own colormap with the following
mymap = [0 0 0.3 0 0 0.4 0 0 0.5 0 0 0.6 0 0 0.8 0 0 1.0]; colormap(mymap)
where each column corresponds to Red, Green, Blue intensities between 0 and 1.
The following page might be helpful.
1 Commento
Tiago Dias
il 29 Giu 2018
Categorie
Scopri di più su Orange in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!