Changing the color of image

6 ビュー (過去 30 日間)
Eric Tang
Eric Tang 2020 年 6 月 26 日
回答済み: Gautam 2024 年 10 月 23 日
How can I change the white portion of the attached picture to blue and the black portion to a yellow/greenish color? Basically what I want to do is changing the picture from black and white to yellow and blue gradient. Thank you in advance!

回答 (2 件)

Image Analyst
Image Analyst 2020 年 6 月 26 日
Use colormap()

Gautam
Gautam 2024 年 10 月 23 日
Hello Eric,
You can use the "winter" colormap to change the color of the image with a gradient of colours from green to blue.
img = imread("blackNWhite body scan.jpg");
I_gray = rgb2gray(img);
% Normalize the grayscale image to be used with the colormap
I_norm = mat2gray(I_gray);
% Apply a colormap (e.g., 'hot') to the grayscale representation
colormap_map = winter(256); % Create a colormap
I_colored = ind2rgb(im2uint8(I_norm), colormap_map);
imshow(I_colored);

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by