MATLAB: Generate a black and white only ColorMap

black and whitecolorcolormap

Hello, i am trying to generate a colormap for an array of values such that values more than 200 are assigned the color black and values less than 200 are assigned the color white. Any idea how I can do that ? I have used the grayscale gradient but I only want black and white color for values if that makes sense.
Thanks!

Best Answer

Try something like this
M = 400*rand(50, 50);
imagesc(M > 200);
colormap(gray)
Related Question