LLIPS  rev33
Light Library for Image ProcesS
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions | Variables
llips_general.c File Reference

About general image handling. More...

#include "llips_includes.h"

Go to the source code of this file.

Functions

CPU_VOID display_img_value (t_img *img, CPU_INT16S colors)
 Display each color of image in ascii. More...
 
t_vect highlight_line (t_img *img, t_pixel pix1, t_pixel pix2, CPU_INT32U RGB)
 Draw a line on image in a given color. More...
 
t_vect pixels_to_vector (t_pixel pix1, t_pixel pix2)
 Convert two pixel into a vector. More...
 
CPU_INT16U vectormodule (t_vect vect)
 Give module of a vector, in "pixel". More...
 
t_area pixel_to_area (t_pixel pix)
 Convert a pixel into a area of 1 x 1. More...
 
CPU_VOID init_area (t_area *area, CPU_INT16U maxwidth, CPU_INT16U maxheight)
 Initialize an area from 0,0 to given values. More...
 
CPU_VOID highlight_area (t_img *img, t_area *area, CPU_INT32U RGB)
 Draw a rectangular area on image in a given color. More...
 
CPU_VOID printf_area (t_area *area)
 Display area corner coordonate in a console. More...
 
CPU_CHAR color_filter (t_img *img_in, t_img *img_out, CPU_INT32U color)
 Create an image with only the color provided. More...
 
CPU_CHAR histogram (t_img *img_in, t_img *img_out)
 Create an image with a view of histogram (RGBY). More...
 
CPU_CHAR luminance (t_img *img_in, t_img *img_out)
 Create an image only luminance data (desaturated image) More...
 
CPU_CHAR apply_linfilter (t_img *img_in, CPU_FP64 **tab_filtre, CPU_INT16S filtersize, CPU_INT32U color, t_img *img_out)
 Apply a predefined filter on the image. More...
 
CPU_FP64 conv_gauss (CPU_INT16S x, CPU_INT16S y, CPU_FP64 sig)
 Gaussian convolution, used to create gaussian filter. More...
 
CPU_VOID create_gauss_filter (CPU_FP64 **tab_filtre, CPU_INT16S filtersize, CPU_FP64 sigma)
 Create a Gaussian filter used to smooth and image. More...
 
CPU_VOID create_average_filter (CPU_FP64 **tab_filtre, CPU_INT16S filtersize)
 Create an average filter for smoothing. More...
 
CPU_INT16S create_laplacian_filter (CPU_FP64 **tab_filtre, CPU_INT08U filtertype)
 Create a laplacian filter for edge detection (return matrix must have a size of 3 or 5) More...
 
CPU_CHAR apply_median_filter (t_img *img_in, CPU_INT16S filtersize, t_img *img_out)
 Apply a median filter on an image. More...
 
CPU_INT08U get_median (CPU_INT08U **table2D, CPU_INT16S filter_range, CPU_INT16S i, CPU_INT16S j)
 Calcultate the median value of an area surrounding a pixel. More...
 
CPU_VOID display_filter_value (CPU_FP64 **tab_filtre, CPU_INT08U filtersize)
 Display values contained in a square filter. More...
 

Variables

const CPU_FP64 lapl_filter_1 [3][3]
 
const CPU_FP64 lapl_filter_2 [3][3]
 
const CPU_FP64 lapl_filter_3 [3][3]
 
const CPU_FP64 lapl_filter_4 [3][3]
 
const CPU_FP64 lapl_filter_5 [5][5]
 

Detailed Description

About general image handling.

Author
MPE

Definition in file llips_general.c.

Function Documentation

CPU_CHAR apply_linfilter ( t_img img_in,
CPU_FP64 **  tab_filtre,
CPU_INT16S  filtersize,
CPU_INT32U  color,
t_img img_out 
)

Apply a predefined filter on the image.

Parameters
img_int_img* - input image
tab_filtreCPU_FP64** - pointer to a 2D Table containing the filter
filtersizeCPU_INT16S - size of the matrix representing the filter
colorCPU_INT32U - color that will be impacted by the filter. If not selected, will be set to zero
img_outt_img* - output image
Returns
CPU_CHAR - status of operation

Definition at line 619 of file llips_general.c.

CPU_CHAR apply_median_filter ( t_img img_in,
CPU_INT16S  filtersize,
t_img img_out 
)

Apply a median filter on an image.

Parameters
img_int_img* - input image
filtersizeCPU_INT16S - filter size
img_outt_img* - output image
Returns
CPU_CHAR - status of operation

Creating a matrix is not necessary prior to use this filter

Definition at line 882 of file llips_general.c.

CPU_CHAR color_filter ( t_img img_in,
t_img img_out,
CPU_INT32U  color 
)

Create an image with only the color provided.

Parameters
img_int_img* - input image
img_outt_img* - output image
colorCPU_INT32U - range of color to work on
Returns
CPU_CHAR error

The parameter color must be a combination of RED | GREEN | BLUE

Definition at line 333 of file llips_general.c.

CPU_FP64 conv_gauss ( CPU_INT16S  x,
CPU_INT16S  y,
CPU_FP64  sig 
)

Gaussian convolution, used to create gaussian filter.

Parameters
xCPU_INT16S - coordinate x in the matrix
yCPU_INT16S - coordinate y in the matrix
sigCPU_FP64 - standard deviation of Gaussian distribution
Returns
CPU_FP64 - result

http://en.wikipedia.org/wiki/Gaussian_filter or http://fr.wikipedia.org/wiki/Filtre_de_Gauss

Definition at line 705 of file llips_general.c.

CPU_VOID create_average_filter ( CPU_FP64 **  tab_filtre,
CPU_INT16S  filtersize 
)

Create an average filter for smoothing.

Parameters
tab_filtreCPU_FP64** - pointer to a 2D table (matrix) that will receive the filter
filtersizeCPU_INT16S - size of the matrix
Returns
CPU_VOID

Definition at line 762 of file llips_general.c.

CPU_VOID create_gauss_filter ( CPU_FP64 **  tab_filtre,
CPU_INT16S  filtersize,
CPU_FP64  sigma 
)

Create a Gaussian filter used to smooth and image.

Parameters
tab_filtreCPU_FP64** - pointer to a 2D table (matrix) that will receive the filter
filtersizeCPU_INT16S - size of the matrix
sigmaCPU_FP64 - standard deviation of Gaussian distribution (higher will smooth more)
Returns
CPU_VOID

Definition at line 727 of file llips_general.c.

CPU_INT16S create_laplacian_filter ( CPU_FP64 **  tab_filtre,
CPU_INT08U  filtertype 
)

Create a laplacian filter for edge detection (return matrix must have a size of 3 or 5)

Parameters
tab_filtreCPU_FP64** - pointer to a 2D table (matrix) that will receive the filter of size (minimum size 3)
filtertypeCPU_INT16S - type of filter to use
Returns
CPU_INT16S - filter size

type 1 { 0,-1, 0} type 2 {0, 1, 0} {-1, 4,-1} {1,-4, 1} { 0,-1, 0} {0, 1, 0}

type 3 {-1,-1,-1} type 4 { 1,-2, 1} {-1, 8,-1} {-2, 4,-2} {-1,-1,-1} { 1,-2, 1}

type 5 { 0, 0,-1, 0, 0} { 0,-1,-2,-1, 0} {-1,-2,16,-2,-1} { 0,-1,-2,-1, 0} { 0, 0,-1, 0, 0}

Definition at line 797 of file llips_general.c.

CPU_VOID display_filter_value ( CPU_FP64 **  tab_filtre,
CPU_INT08U  filtersize 
)

Display values contained in a square filter.

Parameters
tab_filtreCPU_FP64** - pointer to matrix filter to display
filtersizeCPU_INT08U - Size of the filter
Returns
CPU_VOID

Definition at line 965 of file llips_general.c.

CPU_VOID display_img_value ( t_img img,
CPU_INT16S  colors 
)

Display each color of image in ascii.

Parameters
imgt_img* - image to display
colorsCPU_INT16S - color layer to display
Returns
CPU_VOID

Definition at line 96 of file llips_general.c.

CPU_INT08U get_median ( CPU_INT08U **  table2D,
CPU_INT16S  filter_range,
CPU_INT16S  i,
CPU_INT16S  j 
)

Calcultate the median value of an area surrounding a pixel.

Parameters
table2DCPU_INT08U** - pixel table
filter_rangeCPU_INT16S - size of the filter
iCPU_INT16S - coordinate of pixel
jCPU_INT16S - coordinate of pixel
Returns
CPU_INT08U - median value

Definition at line 939 of file llips_general.c.

CPU_VOID highlight_area ( t_img img,
t_area area,
CPU_INT32U  RGB 
)

Draw a rectangular area on image in a given color.

Parameters
imgt_img* - image to modify (also output)
areat_area* - area to highlight
RGBCPU_INT32U - highlight color
Returns
CPU_VOID

Helpfull macro to define color is SetRGB(r,g,b), with value between 0 and 255

Definition at line 278 of file llips_general.c.

t_vect highlight_line ( t_img img,
t_pixel  pix1,
t_pixel  pix2,
CPU_INT32U  RGB 
)

Draw a line on image in a given color.

Warning
NOT FUNCTIONNAL
Parameters
imgt_img* - image to modify (also output)
pix1t_pixel - first point of line
pix2t_pixel - second point of line
RGBCPU_INT32U - color of the line
Returns
t_vect - vector representing the line

Needs to be done Helpfull macro to define color is SetRGB(r,g,b), with value between 0 and 255

Definition at line 172 of file llips_general.c.

CPU_CHAR histogram ( t_img img_in,
t_img img_out 
)

Create an image with a view of histogram (RGBY).

Parameters
img_int_img* - input image
img_outt_img* - output image
Returns
CPU_CHAR - status of operation

Width and precision of histogram depend on image width

Definition at line 392 of file llips_general.c.

CPU_VOID init_area ( t_area area,
CPU_INT16U  maxwidth,
CPU_INT16U  maxheight 
)

Initialize an area from 0,0 to given values.

Parameters
areat_area* - pointer to initialized area
maxwidthCPU_INT16U - width of area
maxheightCPU_INT16U - height of area
Returns
CPU_VOID

Definition at line 255 of file llips_general.c.

CPU_CHAR luminance ( t_img img_in,
t_img img_out 
)

Create an image only luminance data (desaturated image)

Parameters
img_int_img* - input image
img_outt_img* - output image
Returns
CPU_CHAR - status of operation

Definition at line 571 of file llips_general.c.

t_area pixel_to_area ( t_pixel  pix)

Convert a pixel into a area of 1 x 1.

Parameters
pixt_pixel - pixel
Returns
t_area - corresponding area

This function is use to be able to draw a pixel using highlight_area() function

Definition at line 229 of file llips_general.c.

t_vect pixels_to_vector ( t_pixel  pix1,
t_pixel  pix2 
)

Convert two pixel into a vector.

Parameters
pix1t_pixel - starting point of vector
pix2t_pixel - ending point of vector
Returns
t_vect - corresponding vector between pix1 and pix2

Definition at line 192 of file llips_general.c.

CPU_VOID printf_area ( t_area area)

Display area corner coordonate in a console.

Parameters
areat_area* - area to display
Returns
CPU_VOID

Definition at line 309 of file llips_general.c.

CPU_INT16U vectormodule ( t_vect  vect)

Give module of a vector, in "pixel".

Parameters
vectt_vect - vector to process
Returns
CPU_INT16U - module of the vector

Definition at line 210 of file llips_general.c.

Variable Documentation

const CPU_FP64 lapl_filter_1[3][3]
Initial value:
= {{ 0,-1, 0},
{-1, 4,-1},
{ 0,-1, 0}}

Definition at line 63 of file llips_general.c.

const CPU_FP64 lapl_filter_2[3][3]
Initial value:
={{0, 1, 0},
{1,-4, 1},
{0, 1, 0}}

Definition at line 67 of file llips_general.c.

const CPU_FP64 lapl_filter_3[3][3]
Initial value:
= {{-1,-1,-1},
{-1, 8,-1},
{-1,-1,-1}}

Definition at line 71 of file llips_general.c.

const CPU_FP64 lapl_filter_4[3][3]
Initial value:
= {{ 1,-2, 1},
{-2, 4,-2},
{ 1,-2, 1}}

Definition at line 75 of file llips_general.c.

const CPU_FP64 lapl_filter_5[5][5]
Initial value:
= { { 0, 0,-1, 0, 0},
{ 0,-1,-2,-1, 0},
{-1,-2,16,-2,-1},
{ 0,-1,-2,-1, 0},
{ 0, 0,-1, 0, 0}}

Definition at line 79 of file llips_general.c.