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

조회 수: 2 (최근 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