How to generate Reddish, Greenish, Blueish, and whiteish images using color images. I'm using this function. If its wrong please change it.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
a=imread('fruit.png');
b=a;
a(:,:,2)=0;
a(:,:,3)=0;
subplot(2,2,1)
imshow(a)
1 commentaire
DGM
le 9 Déc 2021
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.
Réponses (1)
DGM
le 9 Déc 2021
Modifié(e) : DGM
le 22 Avr 2022
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 commentaires
DGM
le 9 Déc 2021
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)
Voir également
Catégories
En savoir plus sur Red dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!