Changing red colour to yellow colour
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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:
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!