image - Convert RGB to HSV -


i want convert rgb values hsv values . if devide 9 28, octave calculate 0. can explain me reason??

function [hsv] = rgbtohsv()     im = imread('picture.png');      r = im(:,:,1);      g = im(:,:,2);      b = im(:,:,3);      len = length(r); % r, g, b should have same length     = 1:len         max = max([r(i),g(i),b(i)]);         min = min([r(i),g(i),b(i)]);         s = 0;         if max == min             h = 0;         elseif max == r(i)             disp(g(i) - b(i)); % 9              disp(max - min);  % 28             h = 0.6 * ( 0 + ( (g(i) - b(i)) / max - min) ); % 0             disp(h) % why 0 if try calculate ( 0 + ( (g(i) - b(i)) / max - min)?         ....             end         return;     end endfunction  rgbtohsv() 

chris :d

you must cast image double doing:

im = double(imread('picture.png')); 

this solve issues happens since image type uint8.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -