Newsgroups: sci.image.processing
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!gatech!swrinde!sdd.hp.com!hp-pcd!hpcvsnz!briand
From: briand@cv.hp.com (Brian Dixon)
Subject: Re: HSI to RGB
Sender: news@hpcvsnz.cv.hp.com (News )
Message-ID: <D7nyJy.459@hpcvsnz.cv.hp.com>
Date: Wed, 26 Apr 1995 22:31:09 GMT
References: <Pine.SUN.3.91.950222221540.10616D-100000@access3.digex.net>
Nntp-Posting-Host: hpcvsgen.cv.hp.com
Organization: Hewlett-Packard
X-Newsreader: TIN [version 1.1 PL9.4]
Lines: 46

Muz Zviman (muzz@access3.digex.net) wrote:
: On Thu, 16 Feb 1995, Ashley Morgan wrote:

: > I am currently looking for a set of equations to convert from :-
: > 	(1) RGB -> HSI
: > 	(2) HSI -> RGB
: >  
: > Can anyone help ?
: > 
[snip]

Boldy copied from The Image Processing Handbook (don't use this info without
buying the book...uh huh):

H = [PI/2 - arctan {(2*R-G-B)/sqrt(3)*(G-B)} + PI; G < B] / 2*PI
I = (R+G+B)/3
S = 1 - [min(R,G,B)/I]

Best way to understand this is to see the biconic graphic representation of
HSI-space.  It's easy to draw your own picture.  Imagine 2 cones, one right-
side-up on top of another which is upside-down.  The point on the top of
the top cone is 'white', while the point on the bottom of the bottom cone
is 'black'.  Greyscale values lie on the line that runs from the top point
to the bottom point.  Green, Yellow, Red, Magenta, Blue, and Cyan are on 6
equidistant points around the base of the cones (in that order, clockwise.)

To map the HSI-space points graphically to the RGB-space points, draw another
diagram for RGB.  (I LIKE pictures...helps my simple mind.)  Draw a cube.
On the top of the cube, label the 4 corners Blue, Magenta, White, and Cyan
(in that order, clockwise).  Now label the bottom corners: Black is directly
below Blue, Red is directly below Magenta, Yellow is directly below White,
and Green is directly below Cyan.  Greyscale values are on the diagonal
from the Black corner to the White corner.

With those diagrams in place, think of HSI-space in the following way:
Distance from the central axis on the biconic HSI-space diagram gives
the Saturation.  The direction specifies the Hue.

Got that?

Brian


--
Brian Dixon, Machine Vision Engineer, Hewlett Packard (Corvallis, Oregon)
503-715-3143 (wk), briand@cv.hp.com (email). "Opinions & attitudes are mine!"
