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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by