How to change particular pixel color of a binary image to other color?

조회 수: 1 (최근 30일)
Asif Hasan
Asif Hasan . 2014년 10월 30일
댓글: Asif Hasan . 2014년 10월 31일
I have a binary image and i want to change the color of the black pixel to green. How do i do that ? Please help. Thanks in advance.
This is the binary image:

채택된 답변

Image Analyst
Image Analyst 2014년 10월 30일
Try this:
%grayImage = imread('cameraman.tif');
%binaryImage = grayImage > 128;
redAndBlueChannel = 255 * uint8(binaryImage);
greenChannel = 255 * ones(size(binaryImage), 'uint8'); % Green Everywhere.
rgbImage = cat(3, redAndBlueChannel, greenChannel, redAndBlueChannel);
Remove the % if you want to demo it using a standard MATLAB demo image.
  댓글 수: 8

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

추가 답변 (1개)

Doug Hull
Doug Hull 2014년 10월 30일
Change colormap?
im = round(rand(10));
colormap([0 1 0; 1 1 1])


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