Convert RGB to HSV
image, image-processing, octave
Solution
You must cast the image into `Double` by doing:
im = double(imread('picture.png'));
This will solve your issues which happens since the image is type `UINT8`.
Problem
i want to convert RGB values to HSV values . But if I devide 9 by 28, octave calculate 0. Can anyone explain me the 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 the same length for i = 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 i get 0 if try to calculate ( 0 + ( (G(i) - B(i)) / MAX - MIN)? .... end return; end endfunction RGBtoHSV() ``` Chris :D