How to change particular pixel color of a binary image to other color?
조회 수: 5(최근 30일)
표시 이전 댓글
Sir,
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:

댓글 수: 0
채택된 답변
Image Analyst
2014년 10월 30일
Try this:
%grayImage = imread('cameraman.tif');
%binaryImage = grayImage > 128;
%subplot(1,2,1);
%imshow(binaryImage);
redAndBlueChannel = 255 * uint8(binaryImage);
greenChannel = 255 * ones(size(binaryImage), 'uint8'); % Green Everywhere.
rgbImage = cat(3, redAndBlueChannel, greenChannel, redAndBlueChannel);
%subplot(1,2,2);
%imshow(rgbImage);
Remove the % if you want to demo it using a standard MATLAB demo image.
추가 답변(1개)
참고 항목
범주
Find more on Red in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!