How do I change image background to red
55 views (last 30 days)
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 on 18 Feb 2014
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.
More Answers (2)
Ravi Shekhar on 29 Mar 2018
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.