Convert HSV to RGB in MATLAB -


i have [h,s,v] colour values.
how can convert them [r,g,b] in matlab?

i've tried algorithm i'm having problems. can me code?

using in-built hsv2rgb function...

% colour in hsv, [hue (0-360), saturation (0-1), value (0-1)] myhsv = [217, 0.4, 0.72]; % hsv2rgb takes hue value in range 0-1, so... myhsv(1) = myhsv(1) / 360; % convert rgb values in range (0-1) myrgbpct = hsv2rgb(myhsv); % convert rgb values in range (0-255) myrgb255 = myrgbpct * 255; 

putting of together, can do

myhsv = [217, 0.4, 0.72]; myrgb255 = hsv2rgb(myhsv ./ [360, 1, 1]) * 255;  >> myrgb255 = [110.16, 138.31, 183.60] 

testing using google's color picker, can see correct solution. if wanted other rgb manipulation within matlab leave values in range (0-1), since matlab uses.

blue

if have many hsv values, store them in mx3 matrix, columns h,s , v. above can do:

myhsv = [217, 0.4, 0.72;          250, 0.5, 0.2;           % ... more rows         ]; myhsv(:,1) = myhsv(:,1) / 360; myrgb255 = hsv2rgb(myhsv) * 255; 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -