How to generate Reddish, Greenish, Blueish, and whiteish images using color images. I'm using this function. If its wrong please change it.

1 次查看(过去 30 天)
a=imread('fruit.png');
b=a;
a(:,:,2)=0;
a(:,:,3)=0;
subplot(2,2,1)
imshow(a)
  1 个评论
DGM
DGM 2021-12-9
Does the code do what you want it to do?
That's certainly one way to create a "reddish" version of an image, but I can imagine many other ways that would produce different "reddish" images. It all depends what you want.

请先登录,再进行评论。

回答(1 个)

DGM
DGM 2021-12-9
编辑:DGM 2022-4-22
There might be many ways to make a "reddish" version of an image. Consider the examples:
% i'm doing this in double for simplicity.
A = im2double(imread('peppers.png'));
% equivalent to 'multiply' (same as what you're doing)
B = A.*permute([1 0 0],[1 3 2]);
imshow(B)
% equivalent to 'screen'
C = 1-((1-A).*(1-permute([1 0 0],[1 3 2])));
figure; imshow(C)
% simple weighted opacity blend
kalph = 0.5;
D = kalph.*A + (1-kalph).*permute([1 0 0],[1 3 2]);
figure; imshow(D)
% simple hue substitution
E = rgb2hsv(A);
E(:,:,1) = 0;
E = hsv2rgb(E);
imshow(E)
% combine luma with red overlay
F = repmat(rgb2gray(A),[1 1 3]).*permute([1 0 0],[1 3 2]);
imshow(F)
These examples are simplified and use implicit array expansion (requires R2016b or newer). To change the color to green or blue (or any other color), simply change the [1 0 0] color tuple to something else. In the case of the hue substitution example, use 0.33 for green or 0.67 for blue.
This is a related question about creating a colorized version of an image:
  3 个评论
DGM
DGM 2021-12-9
I don't know what "whiteish" would mean in the case of 'multiply' or 'hue' blending. You never really clarified what you were after.
A = im2double(imread('peppers.png'));
% simple weighted opacity blend
kalph = 0.5;
D = kalph.*A + (1-kalph).*permute([1 1 1],[1 3 2]);
figure; imshow(D)
% simple saturation swap
% hsv is pretty terrible for S adjustments
E = rgb2hsv(A);
E(:,:,2) = 0;
E = hsv2rgb(E);
imshow(E)
% combine luma with white overlay
F = repmat(rgb2gray(A),[1 1 3]).*permute([1 0 0],[1 3 2]);
% which simplifies in this case to:
F = repmat(rgb2gray(A),[1 1 3]);
imshow(F)

请先登录,再进行评论。

类别

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