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 日間)
Kiha Kim
Kiha Kim 2021 年 12 月 9 日
編集済み: DGM 2022 年 4 月 22 日
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 件のコメント
Kiha Kim
Kiha Kim 2021 年 12 月 9 日
Can I ask what is the code of whiteish?
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 Center および File ExchangeRed についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by