How do I change image background to red

9 ビュー (過去 30 日間)
Kirti
Kirti 2014 年 2 月 18 日
コメント済み: Image Analyst 2018 年 9 月 20 日
I have an image with black background, which I got from imfreehand function. I want to change that black background to red. Following is link for image.

採用された回答

Image Analyst
Image Analyst 2014 年 2 月 18 日
background = grayImage == 0; % Find black pixels.
redChannel = grayImage;
redChannel(background) = 255; % Set black pixels to max value.
% Create true color image.
rgbImage = cat(3, redChannel, grayImage, grayImage);
imshow(rgbImage); % Display it.
  5 件のコメント
Image Analyst
Image Analyst 2014 年 2 月 20 日
numberOfBackgroundPixels = sum(background(:)); % Red/white pixels in background.
numberOfROIPixels = numel(background) - numberOfBackgroundPixels;
Kirti
Kirti 2014 年 2 月 21 日
I got gray scale Image with red background as per your code. In next step of Image processing I want to binarize only region of Interest keeping red background as it is. but when I apply im2bw all image convert into black and white, even red background. So what is the solution for keeping red background as it is and convert gray image into binary

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

その他の回答 (2 件)

Ravi Shekhar
Ravi Shekhar 2018 年 3 月 29 日
Hi, you can use following MATLAB code to change the color scheme of a gray image.
gray_image = imread('cameraman.tif');
map = colormap('autumn');
rgb_image = ind2rgb(gray_image,map);
You can get different color schemes under 'colormap' function in MATLAB.

hf fh
hf fh 2018 年 9 月 19 日
Please help me I have an image and I want to make the background color white I used the previous method but did not good out with me
  5 件のコメント
hf fh
hf fh 2018 年 9 月 20 日
To make sure there is no noise in the image and also make sure the edges of the image
Image Analyst
Image Analyst 2018 年 9 月 20 日
Making the surround white does not make sure there is no noise in the image. And you didn't finish the second part of the sentence about making sure the edges.....are what?

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by