Plot an array greyscale but certain pixels marked in red

3 次查看(过去 30 天)
I have an MxN array of integers that makes an image that can be plotted with imagesc. I'd like to plot the whole image with greyscale but plot all pixels that have value X in red. Any thoughts?

采纳的回答

Walter Roberson
Walter Roberson 2012-1-24
mymap = gray; %copy the grayscale map
mymap(SomeIndex,:) = [1 0 0]; %set one particular entry to be red
imagesc(YourImage);
colormap(mymap);
This code does require that you figure out what map index the value X will be mapped to by imagesc.
There are alternatives involving overlaying a red image of exactly the same size that is transparent everywhere except for the places X is. This requires OpenGL (no other renderer handles transparency)
  1 个评论
Jason
Jason 2012-1-24
I knew it had to be easy, but I didn't know it was that easy to create a customized color map. Thanks Walter, great answer!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by