Plot an array greyscale but certain pixels marked in red

조회 수: 4 (최근 30일)
Jason
Jason 2012년 1월 23일
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