How to color a binary image?

조회 수: 3 (최근 30일)
Sabarinathan Vadivelu
Sabarinathan Vadivelu 2012년 10월 2일
Suppose a binary image is considered, which consists of two colors. Is it possible to assign red color to the white portions in the image?
  댓글 수: 2
Jan
Jan 2012년 10월 2일
편집: Jan 2012년 10월 2일
Yes.
A binary image consiste of two colors, 0 and 1. Which of them do you call "red" and where does the color information come from?
Sabarinathan Vadivelu
Sabarinathan Vadivelu 2012년 10월 2일
Pixels with 1 should be coloured as red. Is it possible?

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2012년 10월 2일
편집: Jan 2012년 10월 2일
bin = rand(320, 200) > 0.5; % Binary test image
R = 1; % Value in range [0, 1]
G = 1;
B = 1;
RGB = cat(3, bin * R, bin * G, bin * B);
Now the pixels which have the value 1 in the bin image have the value [R,G,B] in the RGB image, while the other pixels are black.
Alternatively:
CMap = [0.5, 0.2, 0.9; 0.1, 0.8, 0.3];
RGB = ind2rgb(bin + 1, CMap)
  댓글 수: 3
Sabarinathan Vadivelu
Sabarinathan Vadivelu 2012년 10월 2일
figure,set(gca,'Color','r'),imshow(outImage);
Where outImage is a binary Image. Is this true?
Jan
Jan 2012년 10월 2일
편집: Jan 2012년 10월 2일
To get red for pixels of color 1 (you still do not specify what the 0 pixels should look like...):
  • Either set B=0 and G=0 in my 1st example
  • Or use the colormap CMap=[0,0,0; 1,0,0] in the 2nd example.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Modify Image Colors에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by