Creating a custom colormap with min and max pixel values, and white as 0?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm looking to create a colourmap where the minimum pixel value to 0 is red to white and 0 to maximum pixel value is white to green.
I can set the caxis to span from the min to max value, but I can't figure out how to ensure that 0 is white and the other values are on the gradients.
Can I somehow create two colourmaps and combine them together? Is there another way to specify the range I want besides caxis?
Thanks
0 Kommentare
Antworten (1)
Image Analyst
am 30 Okt. 2017
You need to decide on a length of a colormap, like 256. Then you need to say row 1 is [1,0,0] which is red and corresponds to the min value, which I guess is negative. Then you need to say the last row is [1,1,1] which is white and corresponds to the max value. Now the 0 value of your data may fall into some row in between 1 and 256 and you need to figure out what that is. Easy to do. Something like
zeroRow = 256 * (0-minValue)/(maxValue-minValue);
Now you need to have row 1 to zeroRow go from red to white, which you can do with linspace(), then have from zeroRow to 256 go from white to green, again using linspace(). Not too hard so give it a try.
1 Kommentar
Siehe auch
Kategorien
Mehr zu White finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!