code.PNG
Please help me to convert from HSV to RGB with this equation

댓글 수: 8

Walter Roberson
Walter Roberson 2019년 12월 5일
Call rgb2hsv()
this formula convert from HSV to RGB not rgb2hsv(), can you help me?
i just can code this
C = F.*saturationValue;
Y = mod(hueValue1/60,2)-1;
l = abs(Y);
X = C.*(1-l);
m = F-C;
how can i code (R',G',B')?
Walter Roberson
Walter Roberson 2019년 12월 5일
Call hsv2rgb() then.
Walter Roberson
Walter Roberson 2019년 12월 5일
Use logical indexing to code the R' G' B' in vectorized form. Or use a for loop with if and elseif
Alvin Alvin
Alvin Alvin 2019년 12월 5일
Can't do that because the color is not same with original, so in this code i convert the original image from RGB to HSV, then i enhancement the V and store with variable F, and want to make HSV with the Enchancement V which is F to RGB again
12.PNG
and this is the Old Value and NEw Value with Enhancement
12 Value.PNG
Walter Roberson
Walter Roberson 2019년 12월 5일
Can't do that
Can't do what ?? Can't use hsv2rgb() ? Can't use logical indexing to code the R' G' B' in vectorized form? Can't use a for loop with if and elseif ?
Alvin Alvin
Alvin Alvin 2019년 12월 5일
can't use logical indexing to code the R' G' B' in vectorized form and Can't use a for loop with if and elseif too
Rp = zeros(size(H));
Gp = zeros(size(H));
Bp = zeros(size(H));
for K = 1 : numel(H)
if H(K) < 60
Rp(K) = C(K);
Gp(K) = X(K);
Bp(K) = 0;
elseif H(K) < 120
Rp(K) = X(K);
Gp(K) = C(K);
Bp(K) = 0;
elseif
and so on
end
end
What prevents you from using a for loop with if and elseif ?

댓글을 달려면 로그인하십시오.

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2019년 12월 5일

0 개 추천

function rgb = HSVtoRGB(H,S,V)
n = numel(H);
C = V.*S;
X = C .* (1 - abs(mod(H/60,2) - 1));
A = [C, X, zeros(n,1)];
i = discretize(H,0:60:360);
j = perms(1:3);
j = j([6,4,2,1,3,5],:);
r = repmat((1:n)',1,3);
rgbs = A(sub2ind([n,3],r,j(i,:)));
rgb = 255*(rgbs + V - C);
end

카테고리

도움말 센터File Exchange에서 Modify Image Colors에 대해 자세히 알아보기

태그

질문:

2019년 12월 5일

댓글:

2019년 12월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by