How do I change image background to red

조회 수: 1 (최근 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 CenterFile Exchange에서 Red에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by