Changing red colour to yellow colour

2 次查看(过去 30 天)
David
David 2020-4-27
评论: David 2020-4-28
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

回答(1 个)

Image Analyst
Image Analyst 2020-4-27
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 个评论
David
David 2020-4-28
hi, thanks for your idea. it really helpful but i want to make it by my code . Thanks you so much

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by