Realtimestagram
Generics | Ports | Types | Constants | Libraries | Use Clauses
rgb2hsv Entity Reference

Description

Creates seperate Hue Saturation Value channels from rgb signal.

dot_rgb2hsv.png
Input and output ports

Introduction

rgb2hsv converts a stream of Red, Green and Blue pixels into their corresponding Hue, Saturation and Value pixels. For more information see the algorithm section.

Features

Functional description

rgb2hsv.timing.png
Timing diagram of rgb2hsv

Algorithm

Hue

The Hue indicates the degrees on the color circle. Starting at 0 degrees with red, 120 degrees for green and 240 degrees for blue. Because 360 degrees does map not correctly on the 8 bits of a byte everything is normalised to the full range of a byte Hue is calculated following the function:

\[H =\left\{\begin{matrix} 0, & R=G=B\\ \frac{(G-B)*60^{\circ}}{max(R,G,B)-min(R,G,B)}\textup{mod}\:360^{\circ}, & R \geq G,B\\ \frac{(B-R)*60^{\circ}}{max(R,G,B)-min(R,G,B)}+120^{\circ}, & G \geq R,B\\ \frac{(R-G)*60^{\circ}}{max(R,G,B)-min(R,G,B)}+240^{\circ} & B \geq R,G \\ \end{matrix}\right.\]

hue_calc.png
Calculation of Hue value from Red Green & Blue

Saturation

The saturation indicates the strength of the color. Saturation is calculated following the function:

\[S =\left\{\begin{matrix} 0, & max(R,G,B)=0 \\ \frac{max(R,G,B)-min(R,G,B)}{max(R,G,B)}, & otherwise\\ \end{matrix}\right.\]

Value

The value indicates the intensity of the pixel. Value is calculated using the following function:

\[ V = max(R,G,B)\]

Rounding issues

TODO calculate the global quantization noise power

Known issues

Example images

RGB image HSV image
amersfoort.png
Amersfoort
rgb2hsv_amersfoort.png
Amersfoort
rainbow.png
Rainbow
rgb2hsv_rainbow.png
Rainbow
hue_gradient.png
Hue gradient
rgb2hsv_hue_gradient.png
Hue gradient
sat_gradient.png
Saturation gradient
rgb2hsv_sat_gradient.png
Saturation gradient
val_gradient.png
Value gradient
rgb2hsv_val_gradient.png
Value gradient

Libraries

ieee 

Use Clauses

std_logic_1164 
numeric_std 
math_real 
 Used for calculation of h_count and v_count port width.

Constants

c_60_degrees  integer := integer ( round ( real ( 60 ) / real ( 360 ) * real ( 2 ** wordsize ) ) )
c_120_degrees  integer := integer ( round ( real ( 120 ) / real ( 360 ) * real ( 2 ** wordsize ) ) )
c_240_degrees  integer := integer ( round ( real ( 240 ) / real ( 360 ) * real ( 2 ** wordsize ) ) )

Types

mux_select_delay ( 0 to 4 ) integer range 0 to 2
max_delay ( 0 to 2 ) integer range 0 to 2 ** wordsize

Generics

wordsize  integer := 8
 input image wordsize in bits

Ports

clk   in std_logic
 completely clocked process
rst   in std_logic
 asynchronous reset
enable   in std_logic
 enables block
pixel_red_i   in std_logic_vector ( ( wordsize - 1 ) downto 0 )
 red input pixel
pixel_green_i   in std_logic_vector ( ( wordsize - 1 ) downto 0 )
 green input pixel
pixel_blue_i   in std_logic_vector ( ( wordsize - 1 ) downto 0 )
 blue input pixel
pixel_hue_o   out std_logic_vector ( ( wordsize - 1 ) downto 0 )
 hue of pixel
pixel_sat_o   out std_logic_vector ( ( wordsize - 1 ) downto 0 )
 saturation of pixel
pixel_val_o   out std_logic_vector ( ( wordsize - 1 ) downto 0 )
 value of pixel

Member Data Documentation

§ c_120_degrees

c_120_degrees integer := integer ( round ( real ( 120 ) / real ( 360 ) * real ( 2 ** wordsize ) ) )
Constant

§ c_240_degrees

c_240_degrees integer := integer ( round ( real ( 240 ) / real ( 360 ) * real ( 2 ** wordsize ) ) )
Constant

§ c_60_degrees

c_60_degrees integer := integer ( round ( real ( 60 ) / real ( 360 ) * real ( 2 ** wordsize ) ) )
Constant

§ clk

clk in std_logic
Port

completely clocked process

§ enable

enable in std_logic
Port

enables block

§ ieee

ieee
Library

§ math_real

math_real
Package

Used for calculation of h_count and v_count port width.

§ max_delay

max_delay ( 0 to 2 ) integer range 0 to 2 ** wordsize
Type

§ mux_select_delay

mux_select_delay ( 0 to 4 ) integer range 0 to 2
Type

§ numeric_std

numeric_std
Package

§ pixel_blue_i

pixel_blue_i in std_logic_vector ( ( wordsize - 1 ) downto 0 )
Port

blue input pixel

§ pixel_green_i

pixel_green_i in std_logic_vector ( ( wordsize - 1 ) downto 0 )
Port

green input pixel

§ pixel_hue_o

pixel_hue_o out std_logic_vector ( ( wordsize - 1 ) downto 0 )
Port

hue of pixel

§ pixel_red_i

pixel_red_i in std_logic_vector ( ( wordsize - 1 ) downto 0 )
Port

red input pixel

§ pixel_sat_o

pixel_sat_o out std_logic_vector ( ( wordsize - 1 ) downto 0 )
Port

saturation of pixel

§ pixel_val_o

pixel_val_o out std_logic_vector ( ( wordsize - 1 ) downto 0 )
Port

value of pixel

§ rst

rst in std_logic
Port

asynchronous reset

§ std_logic_1164

std_logic_1164
Package

§ wordsize

wordsize integer := 8
Generic

input image wordsize in bits


The documentation for this class was generated from the following file: