Realtimestagram
Libraries | Use Clauses | Constants | Types | Procedures | Functions
image_io_pkg Package Reference

Description

Provides functionality for easy reading and writing of netbpm images.

Reading and writing of images has been placed into single package. This way writing and reading them is centralized and easier.

Netbpm image format

It is completly designed around netbpm image format. This plain version of this format are ascii based and make them suitable for trivial reading and writing from VHDL. The images can directly be viewed in any image viewer and are very protable and recognized by many tools.

For a description of this format see the Wikipedia page about Netbpm.

Typical reading usage

 -- First read the header
 read_pbmplus_header( pgm_width, pgm_height, max_pixel_value, pgm, file_input_pixel );
 
 -- Then read the pixels
 read_pixel(file_input_pixel, pixel_tmp, end_of_file);

Typical writing usage

 -- First write the header
 write_pbmplus_header( pgm_width, pgm_height, max_pixel_value, pgm, file_output_pixel );

 -- Then write the pixels
 write_pixel( val, file_output_pixel);
Package Body >> image_io_pkg

Functions

string   pad_string (
arg_str: in string
ret_len_c: in natural 10
fill_char_c: in character ' '
)

Procedures

  read_pbmplus_header(
constant exp_width: in integer
constant exp_height: in integer
constant exp_max_value: in integer
constant exp_type_of_pbm: in pbmplustype
)
 Generic procedure for reading pbm plus headers.
  write_pbmplus_header(
constant p_width: in integer
constant p_height: in integer
constant max_value: in integer
constant type_of_pbm: in pbmplustype
)
 generic procedure for writing pbm plus headers
  read_pixel( variable pixel: out integer ,signal end_of_file: out std_logic )
 generic procedure for reading single pixel value from pbm file to variable
  read_pixel( signal pixel: out std_logic_vector ,signal end_of_file: out std_logic )
 generic procedure for reading single pixel value from pbm file to signal
  read_rgb_pixel(
variable pixel_r: out integer
variable pixel_g: out integer
variable pixel_b: out integer
signal end_of_file: out std_logic
)
 generic procedure to read rgb variable from a file
  read_rgb_pixel(
signal pixel_r: out std_logic_vector ( wordsize - 1 downto 0 )
signal pixel_g: out std_logic_vector ( wordsize - 1 downto 0 )
signal pixel_b: out std_logic_vector ( wordsize - 1 downto 0 )
signal end_of_file: out std_logic
)
  write_pixel( variable pixel: in integer )
 generic procedure for writing single pixel value from variable to pbm file
  write_pixel( signal pixel: in std_logic_vector )
 generic procedure for writing single pixel value from signal to pbm file
  write_bin_pixel( variable pixel: in boolean )
  write_bin_pixel( signal pixel: in std_logic )
  write_rgb_pixel(
variable pixel_r: in integer
variable pixel_g: in integer
variable pixel_b: in integer
)
  write_rgb_pixel(
signal pixel_r: in unsigned ( 7 downto 0 )
signal pixel_g: in unsigned ( 7 downto 0 )
signal pixel_b: in unsigned ( 7 downto 0 )
)
  write_ycbcr_pixel(
variable pixel_y: in integer
variable pixel_cb: in integer
variable pixel_cr: in integer
)
  write_ycbcr_pixel(
signal pixel_y: in unsigned ( 9 downto 0 )
signal pixel_cb: in unsigned ( 9 downto 0 )
signal pixel_cr: in unsigned ( 9 downto 0 )
)
  rgb_to_ycbcr(
variable r: in unsigned ( 7 downto 0 )
variable g: in unsigned ( 7 downto 0 )
variable b: in unsigned ( 7 downto 0 )
variable y: out unsigned ( 9 downto 0 )
variable cb: out unsigned ( 9 downto 0 )
variable cr: out unsigned ( 9 downto 0 )
)
 procedure to convert rgb variables into corresponding ycbcr components
  ycbcr_to_rgb(
variable y: in unsigned ( 9 downto 0 )
variable cb: in unsigned ( 9 downto 0 )
variable cr: in unsigned ( 9 downto 0 )
variable r: out unsigned ( 7 downto 0 )
variable g: out unsigned ( 7 downto 0 )
variable b: out unsigned ( 7 downto 0 )
)
 procedure to convert ycbcr variables into corresponding rgb components

Libraries

ieee 
 use standard library

Use Clauses

std_logic_1164 
 use std_logic_vector
numeric_std 
 needed for colorscheme calculations
textio 
 used for writing and reading images
math_real 
 used only for calculation of constants

Constants

wordsize  integer := 8
 Number of bits in a pixel.

Types

pbmplustype ( pbm , pgm , ppm )
 Enumeration for type of pbm.

Member Function Documentation

§ pad_string()

string pad_string (   arg_str in string ,
  ret_len_c in natural 10 ,
  fill_char_c in character ' '  
)
Function

function to pad strings with a fill character

Parameters
[in]arg_strthe input string that has to be padded
[in]ret_len_cthe length of the output string. (must be larger than length of the input string)
[in]fill_char_cthe filling character that should be used to pad the input string
Returns
string arg_str padded up to length ret_len_c with charachter fill_char_c

§ read_pbmplus_header()

read_pbmplus_header ( constant   exp_width in integer ,
constant   exp_height in integer ,
constant   exp_max_value in integer ,
constant   exp_type_of_pbm in pbmplustype  
)
Procedure

Generic procedure for reading pbm plus headers.

Reads the header from a file and compares the read values to the expected files, by using this it can be asserted the correct input image was provided

Parameters
[in]exp_widthExpected width in number of pixels
[in]exp_heightExpected height in number of pixels
[in]exp_max_valueExpected maximum value
[in]exp_type_of_pbmExpected pbmplustype

§ read_pixel() [1/2]

read_pixel ( variable   pixel out integer ,
signal   end_of_file out std_logic  
)
Procedure

generic procedure for reading single pixel value from pbm file to variable

Reads a single pixel every call from the specified file and outputs it as variable

Parameters
[in]pbmplus_filefile to read from
[out]pixelvariable to place value in
[out]end_of_filesignal that is true when end_of_file is reached

§ read_pixel() [2/2]

read_pixel ( signal   pixel out std_logic_vector ,
signal   end_of_file out std_logic  
)
Procedure

generic procedure for reading single pixel value from pbm file to signal

Reads a single pixel every call from the specified file

Parameters
[in]pbmplus_filefile to read from
[out]pixelsignal to place value in
[out]end_of_filesignal that is true when end_of_file is reached

§ read_rgb_pixel() [1/2]

read_rgb_pixel ( variable   pixel_r out integer ,
variable   pixel_g out integer ,
variable   pixel_b out integer ,
signal   end_of_file out std_logic  
)
Procedure

generic procedure to read rgb variable from a file

Reads a single rgb pixel every call from the specified file and outputs it as seperate variable per color channel.

Parameters
[in]pbmplus_filefile to read from
[out]pixel_rvariable to place red pixel value in
[out]pixel_gvariable to place green pixel value in
[out]pixel_bvariable to place blue pixel value in
[out]end_of_filesignal that is true when end_of_file is reached

§ read_rgb_pixel() [2/2]

read_rgb_pixel ( signal   pixel_r out std_logic_vector( wordsize - 1 downto 0 ) ,
signal   pixel_g out std_logic_vector( wordsize - 1 downto 0 ) ,
signal   pixel_b out std_logic_vector( wordsize - 1 downto 0 ) ,
signal   end_of_file out std_logic  
)
Procedure

Reads a single rgb pixel every call from the specified file and outputs it as seperate signal per color channel.

Parameters
[in]pbmplus_filefile to read from
[out]pixel_rsignal to place red pixel value in
[out]pixel_gsignal to place green pixel value in
[out]pixel_bsignal to place blue pixel value in
[out]end_of_filesignal that is true when end_of_file is reached

§ rgb_to_ycbcr()

rgb_to_ycbcr ( variable   r in unsigned( 7 downto 0 ) ,
variable   g in unsigned( 7 downto 0 ) ,
variable   b in unsigned( 7 downto 0 ) ,
variable   y out unsigned( 9 downto 0 ) ,
variable   cb out unsigned( 9 downto 0 ) ,
variable   cr out unsigned( 9 downto 0 )  
)
Procedure

procedure to convert rgb variables into corresponding ycbcr components

§ write_bin_pixel() [1/2]

write_bin_pixel ( variable   pixel in boolean  
)
Procedure

generic procedure to write binary variable of a file the header must be written with pbm as image type

§ write_bin_pixel() [2/2]

write_bin_pixel ( signal   pixel in std_logic  
)
Procedure

generic procedure to write binary signal of a file the header must be written with pbm as image type

§ write_pbmplus_header()

write_pbmplus_header ( constant   p_width in integer ,
constant   p_height in integer ,
constant   max_value in integer ,
constant   type_of_pbm in pbmplustype  
)
Procedure

generic procedure for writing pbm plus headers

Parameters
[in]p_widthWidth in number of pixels
[in]p_heightHeight in number of pixels
[in]max_valueMaximum value
[in]type_of_pbmpbmplustype

§ write_pixel() [1/2]

write_pixel ( variable   pixel in integer  
)
Procedure

generic procedure for writing single pixel value from variable to pbm file

§ write_pixel() [2/2]

write_pixel ( signal   pixel in std_logic_vector  
)
Procedure

generic procedure for writing single pixel value from signal to pbm file

§ write_rgb_pixel() [1/2]

write_rgb_pixel ( variable   pixel_r in integer ,
variable   pixel_g in integer ,
variable   pixel_b in integer  
)
Procedure

generic procedure to write rgb variable of a file the header must be written with ppm as image type

§ write_rgb_pixel() [2/2]

write_rgb_pixel ( signal   pixel_r in unsigned( 7 downto 0 ) ,
signal   pixel_g in unsigned( 7 downto 0 ) ,
signal   pixel_b in unsigned( 7 downto 0 )  
)
Procedure

generic procedure to write rgb signal of a file the header must be written with ppm as image type

§ write_ycbcr_pixel() [1/2]

write_ycbcr_pixel ( variable   pixel_y in integer ,
variable   pixel_cb in integer ,
variable   pixel_cr in integer  
)
Procedure

generic procedure to write ycbcr variable of a file the header must be written with ppm as image type

§ write_ycbcr_pixel() [2/2]

write_ycbcr_pixel ( signal   pixel_y in unsigned( 9 downto 0 ) ,
signal   pixel_cb in unsigned( 9 downto 0 ) ,
signal   pixel_cr in unsigned( 9 downto 0 )  
)
Procedure

generic procedure to write ycbcr signal of a file the header must be written with ppm as image type

§ ycbcr_to_rgb()

ycbcr_to_rgb ( variable   y in unsigned( 9 downto 0 ) ,
variable   cb in unsigned( 9 downto 0 ) ,
variable   cr in unsigned( 9 downto 0 ) ,
variable   r out unsigned( 7 downto 0 ) ,
variable   g out unsigned( 7 downto 0 ) ,
variable   b out unsigned( 7 downto 0 )  
)
Procedure

procedure to convert ycbcr variables into corresponding rgb components

Member Data Documentation

§ ieee

ieee
Library

use standard library

§ math_real

math_real
Package

used only for calculation of constants

§ numeric_std

numeric_std
Package

needed for colorscheme calculations

§ pbmplustype

pbmplustype ( pbm , pgm , ppm )
Type

Enumeration for type of pbm.

There are three types of pbm available, these types are specified in the table below

Type Description
pbm Supports monochrome bitmaps (1 bit per pixel).
pgm Supports greyscale images. Reads either pbm or pgm formats and writes pgm format.
ppm Supports full-color images. Reads either pbm, pgm, or ppm formats, writes ppm format.

§ std_logic_1164

std_logic_1164
Package

use std_logic_vector

§ textio

textio
Package

used for writing and reading images

§ wordsize

wordsize integer := 8
Constant

Number of bits in a pixel.


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