Changing red colour to yellow colour
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 27 Apr 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:
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!