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

4 ビュー (過去 30 日間)
Asif Hasan
Asif Hasan 2014 年 10 月 30 日
コメント済み: Asif Hasan 2014 年 10 月 31 日
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:

採用された回答

Image Analyst
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.
  8 件のコメント
Image Analyst
Image Analyst 2014 年 10 月 30 日
It works just fine. Here's proof:
s = load('binaryimage.mat')
binaryImage = s.show;
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);
Asif Hasan
Asif Hasan 2014 年 10 月 31 日
Thanks sir it worked.

サインインしてコメントする。

その他の回答 (1 件)

Doug Hull
Doug Hull 2014 年 10 月 30 日
Change colormap?
clf
im = round(rand(10));
imshow(im)
colormap([0 1 0; 1 1 1])

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by