Changing red colour to yellow colour

2 vues (au cours des 30 derniers jours)
David
David le 27 Avr 2020
Commenté : David le 28 Avr 2020
Hi,
I am a newbie to matlab and I am having problem with changing my picture which I named red_dragon.jpg file. The dragon is red so i want to change the skin to yellow. So far, I have learned to change the red,blue,green colour but i have searched for more information to change the picture to yellow color
Here is my trial. I am pretty sure that there is point that I am doing wrong and I can't figure it out. Can someone help me? I know there is various way to change the colour but i really want to follow this script.
Thanks you
clc
red_dragon=imread('red_dragon.jpg');
yellow_dragon=red_dragon;
dims=size(red_dragon);
for a=1:dims(1);
for b=1:dims(2);
if red_dragon(a,b,1)>1.2*mean(red_dragon(a,b,:))
yellow_dragon(:,:,0)=red_dragon(a,b,1);
yellow_dragon(a,b,1:3)=0;
image(yellow_dragon)
end
end
end

Réponses (1)

Image Analyst
Image Analyst le 27 Avr 2020
Convert to HSV color space with rgb2hsv(), then alter the H channel somehow, then convert back with hsv2rgb(). For example
hsvImage = rgb2hsv(rgbImage);
hsvImage(:, :, 1) = hsvImage(:, :, 1) + 0.5;
rgbImage = hsv2rgb(hsvImage);
Attached are some full demos.
Change red into green:
Change red into blue:
  1 commentaire
David
David le 28 Avr 2020
hi, thanks for your idea. it really helpful but i want to make it by my code . Thanks you so much

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by