ho_pixbuf.h

Langue: en

Version: 167512 (fedora - 05/07/09)

Section: 3 (Bibliothèques de fonctions)

Sommaire

NAME

src/ho_pixbuf.h - libhocr C language header.

SYNOPSIS


#include <ho_bitmap.h>
#include <ho_objmap.h>
#include <ho_layout.h>

Data Structures


struct string_data
helper string struct for non-null-terminated strings
struct ho_pixbuf
libhocr pixbuf map struct (copy gtk pixbuf)

Defines


#define HO_PIXBUF_H 1

#define ho_pixbuf_min3(a, b, c) ((((a)<(b))&&((a)<(c))) ? (a) : (((b)<(c)) ? (b) : (c)))

#define ho_pixbuf_max3(a, b, c) ((((a)>(b))&&((a)>(c))) ? (a) : (((b)>(c)) ? (b) : (c)))

#define ho_pixbuf_set(m, x, y, col, val) (((m)->data)[(x)*(m)->n_channels+(y)*(m)->rowstride+(col)]=(val))

#define ho_pixbuf_get(m, x, y, col) (((m)->data)[(x)*(m)->n_channels+(y)*(m)->rowstride+(col)])

#define ho_pixbuf_get_n_channels(m) ((m)->n_channels)

#define ho_pixbuf_get_width(m) ((m)->width)

#define ho_pixbuf_get_height(m) ((m)->height)

#define ho_pixbuf_get_rowstride(m) ((m)->rowstride)

#define ho_pixbuf_get_data(m) ((m)->data)

Functions


ho_pixbuf * ho_pixbuf_new (const unsigned char n_channels, const int width, const int height, const int rowstride)

ho_pixbuf * ho_pixbuf_clone (const ho_pixbuf *m)

ho_pixbuf * ho_pixbuf_clone_window (const ho_pixbuf *m, const int x, const int y, const int width, const int height)

int ho_pixbuf_set_data (ho_pixbuf *pix, const char *data)

string_data ho_pixbuf_get_data_string (ho_pixbuf *pix)

ho_pixbuf * ho_pixbuf_new_from_bitmap (const ho_bitmap *bit_in)

ho_pixbuf * ho_pixbuf_new_from_objmap (const ho_objmap *obj_in, const unsigned char min, const unsigned char max)

ho_pixbuf * ho_pixbuf_new_from_layout (const ho_layout *lay_in, const unsigned char show_grid, const ho_bitmap *m_text, const unsigned char text_block_r, const unsigned char text_block_g, const unsigned char text_block_b, const unsigned char text_block_a, const unsigned char text_block_frame_width, const unsigned char line_block_r, const unsigned char line_block_g, const unsigned char line_block_b, const unsigned char line_block_a, const unsigned char line_block_frame_width, const unsigned char word_block_r, const unsigned char word_block_g, const unsigned char word_block_b, const unsigned char word_block_a, const unsigned char word_block_frame_width, const unsigned char font_block_r, const unsigned char font_block_g, const unsigned char font_block_b, const unsigned char font_block_a, const unsigned char font_block_frame_width)

ho_pixbuf * ho_pixbuf_to_rgb (const ho_pixbuf *pix_in)

int ho_pixbuf_free (ho_pixbuf *pix)

ho_pixbuf * ho_pixbuf_color_to_gray (const ho_pixbuf *pix)

ho_pixbuf * ho_pixbuf_color_to_red (const ho_pixbuf *pix)

ho_pixbuf * ho_pixbuf_color_to_green (const ho_pixbuf *pix)

ho_pixbuf * ho_pixbuf_color_to_blue (const ho_pixbuf *pix)

ho_pixbuf * ho_pixbuf_scale2 (const ho_pixbuf *pix)

ho_pixbuf * ho_pixbuf_scale3 (const ho_pixbuf *pix)

ho_pixbuf * ho_pixbuf_scale4 (const ho_pixbuf *pix)

ho_pixbuf * ho_pixbuf_scale8 (const ho_pixbuf *pix)

ho_pixbuf * ho_pixbuf_scale (const ho_pixbuf *pix, const unsigned char scale)

unsigned char ho_pixbuf_minmax (const ho_pixbuf *pix, unsigned char *min, unsigned char *max)

ho_pixbuf * ho_pixbuf_linear_filter (const ho_pixbuf *pix)

ho_bitmap * ho_pixbuf_to_bitmap (const ho_pixbuf *pix, unsigned char threshold)

ho_bitmap * ho_pixbuf_to_bitmap_by_color (const ho_pixbuf *pix, unsigned char min_red, unsigned char max_red, unsigned char min_green, unsigned char max_green, unsigned char min_blue, unsigned char max_blue)

ho_bitmap * ho_pixbuf_to_bitmap_adaptive (const ho_pixbuf *pix, unsigned char threshold, unsigned char size, unsigned char adaptive_threshold)

ho_bitmap * ho_pixbuf_to_bitmap_adaptive_fine (const ho_pixbuf *pix, unsigned char threshold, unsigned char size, unsigned char adaptive_threshold)

ho_bitmap * ho_pixbuf_to_bitmap_wrapper (const ho_pixbuf *pix_in, const unsigned char scale, const unsigned char adaptive, const unsigned char threshold, const unsigned char a_threshold, const unsigned char size)

int ho_pixbuf_draw_line (ho_pixbuf *m, const int x1, const int y1, const int x2, const int y2, const unsigned char red, const unsigned char green, const unsigned char blue)

int ho_pixbuf_draw_box (ho_pixbuf *m, const int x, const int y, const int width, const int height, const unsigned char red, const unsigned char green, const unsigned char blue, const unsigned char alpha)

int ho_pixbuf_draw_box_empty (ho_pixbuf *m, const int x, const int y, const int width, const int height, const unsigned char red, const unsigned char green, const unsigned char blue)

int ho_pixbuf_draw_horizontal_scale (ho_pixbuf *m, const int x1, const int y1, const int length, const int step, const unsigned char red, const unsigned char green, const unsigned char blue)

int ho_pixbuf_draw_vertical_scale (ho_pixbuf *m, const int x1, const int y1, const int length, const int step, const unsigned char red, const unsigned char green, const unsigned char blue)

int ho_pixbuf_draw_grid (ho_pixbuf *m, const int size, const int step, const unsigned char red, const unsigned char green, const unsigned char blue)

int ho_pixbuf_draw_bitmap (ho_pixbuf *m, const ho_bitmap *bit_in, const unsigned char red, const unsigned char green, const unsigned char blue, const unsigned char alpha)

int ho_pixbuf_draw_rgb_bitmap (ho_pixbuf *m, const ho_bitmap *bit_in_red, const ho_bitmap *bit_in_green, const ho_bitmap *bit_in_blue)

int ho_pixbuf_draw_rgb_pixbufs (ho_pixbuf *m, const ho_pixbuf *bit_in_red, const ho_pixbuf *bit_in_green, const ho_pixbuf *bit_in_blue)

int ho_pixbuf_draw_bitmap_at (ho_pixbuf *m, const ho_bitmap *bit_in, const int x1, const int y1, const unsigned char red, const unsigned char green, const unsigned char blue, const unsigned char alpha)

ho_pixbuf * ho_pixbuf_pnm_load (const char *filename)

int ho_pixbuf_pnm_save (const ho_pixbuf *pix, const char *filename)

ho_pixbuf * ho_pixbuf_bw_tiff_load (const char *filename)

int ho_pixbuf_bw_tiff_save (const ho_pixbuf *pix, const char *filename)

Detailed Description

libhocr C language header.

libhocr - LIBrary for Hebrew Optical Character Recognition

Define Documentation

#define HO_PIXBUF_H 1

#define ho_pixbuf_min3(a, b, c) ((((a)<(b))&&((a)<(c))) ? (a) : (((b)<(c)) ? (b) : (c)))

#define ho_pixbuf_max3(a, b, c) ((((a)>(b))&&((a)>(c))) ? (a) : (((b)>(c)) ? (b) : (c)))

#define ho_pixbuf_set(m, x, y, col, val) (((m)->data)[(x)*(m)->n_channels+(y)*(m)->rowstride+(col)]=(val))

#define ho_pixbuf_get(m, x, y, col) (((m)->data)[(x)*(m)->n_channels+(y)*(m)->rowstride+(col)])

#define ho_pixbuf_get_n_channels(m) ((m)->n_channels)

#define ho_pixbuf_get_width(m) ((m)->width)

#define ho_pixbuf_get_height(m) ((m)->height)

#define ho_pixbuf_get_rowstride(m) ((m)->rowstride)

#define ho_pixbuf_get_data(m) ((m)->data)

Function Documentation

ho_pixbuf* ho_pixbuf_new (const unsigned char n_channels, const int width, const int height, const int rowstride)

new ho_pixbuf

Parameters:

n_channels number of color channels
height hight of pixbuf in pixels
width width of pixbuf in pixels
rowstride number of bytes in a row

Returns:

newly allocated ho_pixbuf

ho_pixbuf* ho_pixbuf_clone (const ho_pixbuf * m)

clone ho_pixbuf

Parameters:

m pointer to a ho_pixbuf image

Returns:

newly allocated gray ho_pixbuf

ho_pixbuf* ho_pixbuf_clone_window (const ho_pixbuf * m, const int x, const int y, const int width, const int height)

clone ho_pixbuf window

Parameters:

m pointer to a ho_pixbuf image
x x-start of window
y y-start of window
width width of window
height height of window

Returns:

newly allocated gray ho_pixbuf

int ho_pixbuf_set_data (ho_pixbuf * pix, const char * data)

copy pixel date to a ho_pixbuf

Parameters:

pix pointer to a ho_pixbuf image
data the pixel data to copy

Returns:

newly allocated gray ho_pixbuf

string_data ho_pixbuf_get_data_string (ho_pixbuf * pix)

get pixel date to a ho_pixbuf as a string

Parameters:

pix pointer to a ho_pixbuf image
a string data struct of the pixbuf data

ho_pixbuf* ho_pixbuf_new_from_bitmap (const ho_bitmap * bit_in)

new ho_pixbuf from ho_bitmap

Parameters:

bit_in pointer to an ho_bitmap image

Returns:

newly allocated gray ho_pixbuf

Referenced by hocr::Hocr::get_bitmap_pixbuf().

ho_pixbuf* ho_pixbuf_new_from_objmap (const ho_objmap * obj_in, const unsigned char min, const unsigned char max)

new ho_pixbuf from ho_objmap

Parameters:

obj_in pointer to an ho_objmap image
min minimal color value
max maximal color value

Returns:

newly allocated color ho_pixbuf

ho_pixbuf* ho_pixbuf_new_from_layout (const ho_layout * lay_in, const unsigned char show_grid, const ho_bitmap * m_text, const unsigned char text_block_r, const unsigned char text_block_g, const unsigned char text_block_b, const unsigned char text_block_a, const unsigned char text_block_frame_width, const unsigned char line_block_r, const unsigned char line_block_g, const unsigned char line_block_b, const unsigned char line_block_a, const unsigned char line_block_frame_width, const unsigned char word_block_r, const unsigned char word_block_g, const unsigned char word_block_b, const unsigned char word_block_a, const unsigned char word_block_frame_width, const unsigned char font_block_r, const unsigned char font_block_g, const unsigned char font_block_b, const unsigned char font_block_a, const unsigned char font_block_frame_width)

new ho_pixbuf from ho_layout

Parameters:

lay_in pointer to an ho_layout image
show_grid show grid on output
m_text text to draw on output
text_block_r red channel of text block
text_block_g green channel of text block
text_block_b blue channel of text block
text_block_a alfa channel of text block
text_block_frame_width frame width of text block
line_block_r red channel of line block
line_block_g green channel of line block
line_block_b blue channel of line block
line_block_a alfa channel of line block
line_block_frame_width frame line of text block
word_block_r red channel of word block
word_block_g green channel of word block
word_block_b blue channel of word block
word_block_a alfa channel of word block
word_block_frame_width frame width of word block
font_block_r red channel of font block
font_block_g green channel of font block
font_block_b blue channel of font block
font_block_a alfa channel of font block
font_block_frame_width frame width of font block

Returns:

newly allocated color ho_pixbuf

Referenced by hocr::Hocr::get_layout_pixbuf().

ho_pixbuf* ho_pixbuf_to_rgb (const ho_pixbuf * pix_in)

new rgb ho_pixbuf from non rgb pixbuf

Parameters:

pix_in pointer the original pixbuf

Returns:

newly allocated rgb color ho_pixbuf

Referenced by hocr::Hocr::get_bitmap_pixbuf().

int ho_pixbuf_free (ho_pixbuf * pix)

free an ho_pixbuf

Parameters:

pix pointer to an ho_pixbuf

Returns:

FALSE

Referenced by hocr::Hocr::get_bitmap_pixbuf(), hocr::Hocr::set_bitmap(), hocr::Hocr::set_pixbuf(), and hocr::Hocr::~Hocr().

ho_pixbuf* ho_pixbuf_color_to_gray (const ho_pixbuf * pix)

converts a color pixbuf to gray one

Parameters:

pix the color ho_pixbuf

Returns:

newly allocated gray ho_pixbuf

ho_pixbuf* ho_pixbuf_color_to_red (const ho_pixbuf * pix)

take the Red channel from an RGB pixbuf

Parameters:

pix the color ho_pixbuf

Returns:

newly allocated gray ho_pixbuf

ho_pixbuf* ho_pixbuf_color_to_green (const ho_pixbuf * pix)

take the Green channel from an RGB pixbuf

Parameters:

pix the color ho_pixbuf

Returns:

newly allocated gray ho_pixbuf

ho_pixbuf* ho_pixbuf_color_to_blue (const ho_pixbuf * pix)

take the Blue channel from an RGB pixbuf

Parameters:

pix the color ho_pixbuf

Returns:

newly allocated gray ho_pixbuf

ho_pixbuf* ho_pixbuf_scale2 (const ho_pixbuf * pix)

scale a gray pixbuf to by 2

Parameters:

pix the input ho_pixbuf

Returns:

newly allocated gray ho_pixbuf

ho_pixbuf* ho_pixbuf_scale3 (const ho_pixbuf * pix)

scale a gray pixbuf to by 3

Parameters:

pix the input ho_pixbuf

Returns:

newly allocated gray ho_pixbuf

ho_pixbuf* ho_pixbuf_scale4 (const ho_pixbuf * pix)

scale a gray pixbuf to by 4

Parameters:

pix the input ho_pixbuf

Returns:

newly allocated gray ho_pixbuf

ho_pixbuf* ho_pixbuf_scale8 (const ho_pixbuf * pix)

scale a gray pixbuf to by 8

Parameters:

pix the input ho_pixbuf

Returns:

newly allocated gray ho_pixbuf

ho_pixbuf* ho_pixbuf_scale (const ho_pixbuf * pix, const unsigned char scale)

scale a gray pixbuf

Parameters:

pix the input ho_pixbuf
scale scale by this factor

Returns:

newly allocated gray ho_pixbuf

unsigned char ho_pixbuf_minmax (const ho_pixbuf * pix, unsigned char * min, unsigned char * max)

get the min and max values in a gray pixbuf

Parameters:

pix gray ho_pixbuf
min a pointer to return the min
max a pointer to return the max

Returns:

FALSE

ho_pixbuf* ho_pixbuf_linear_filter (const ho_pixbuf * pix)

aplay a linear filter to a gray pixbuf

Parameters:

pix the input ho_pixbuf

Returns:

newly allocated gray ho_pixbuf

ho_bitmap* ho_pixbuf_to_bitmap (const ho_pixbuf * pix, unsigned char threshold)

convert a color or gray pixbuf to bitmap

Parameters:

pix the input ho_pixbuf
threshold the threshold to use 0..100

Returns:

newly allocated b/w ho_bitmap

ho_bitmap* ho_pixbuf_to_bitmap_by_color (const ho_pixbuf * pix, unsigned char min_red, unsigned char max_red, unsigned char min_green, unsigned char max_green, unsigned char min_blue, unsigned char max_blue)

convert a color or gray pixbuf to bitmap

Parameters:

pix the input ho_pixbuf
min_red the min threshold for red channel
max_red the max threshold for red channel
min_green the min threshold for green channel
max_gren the max threshold for green channel
min_blue the min threshold for blue channel
max_blue the max threshold for blue channel

Returns:

newly allocated b/w ho_bitmap

ho_bitmap* ho_pixbuf_to_bitmap_adaptive (const ho_pixbuf * pix, unsigned char threshold, unsigned char size, unsigned char adaptive_threshold)

convert a gray pixbuf to bitmap using adaptive thresholding

Parameters:

pix the input ho_pixbuf
threshold the threshold to use 0..100
size block size for the adaptive steps
adaptive_threshold the threshold to use for adaptive thresholding 0..100

Returns:

newly allocated b/w ho_bitmap

ho_bitmap* ho_pixbuf_to_bitmap_adaptive_fine (const ho_pixbuf * pix, unsigned char threshold, unsigned char size, unsigned char adaptive_threshold)

convert a gray pixbuf to bitmap using better adaptive thresholding

Parameters:

pix the input ho_pixbuf
threshold the threshold to use 0..100
size block size for the adaptive steps
adaptive_threshold the threshold to use for adaptive thresholding 0..100

Returns:

newly allocated b/w ho_bitmap

ho_bitmap* ho_pixbuf_to_bitmap_wrapper (const ho_pixbuf * pix_in, const unsigned char scale, const unsigned char adaptive, const unsigned char threshold, const unsigned char a_threshold, const unsigned char size)

convert a color of gray pixbuf to bitmap wrapper function

Parameters:

pix_in the input ho_pixbuf
scale the scale to use
adaptive what type of thresholding to use. 0-normal,1-no,2-fine.
threshold the threshold to use 0..100
a_threshold the threshold to use for adaptive thresholding 0..100
size kernel size to use for adaptive thresholding

Returns:

newly allocated b/w ho_bitmap

int ho_pixbuf_draw_line (ho_pixbuf * m, const int x1, const int y1, const int x2, const int y2, const unsigned char red, const unsigned char green, const unsigned char blue)

draw a line from x1,y1 to x2,y2

Parameters:

m a ho_pixbuf
x1 x cordinate of start point
y1 y cordinate of start point
x2 x cordinate of end point
y2 y cordinate of end point
red value of red channel
green value of green channel
blue value of blue channel

Returns:

FALSE

int ho_pixbuf_draw_box (ho_pixbuf * m, const int x, const int y, const int width, const int height, const unsigned char red, const unsigned char green, const unsigned char blue, const unsigned char alpha)

draw a box on pixbuf

Parameters:

m the pixbuf to draw on
x x-start of box
y y-start of box
width width of box
height height of box
red value of red channel
green value of green channel
blue value of blue channel
alpha value of alpha channel

Returns:

FALSE

int ho_pixbuf_draw_box_empty (ho_pixbuf * m, const int x, const int y, const int width, const int height, const unsigned char red, const unsigned char green, const unsigned char blue)

draw an empty box on pixbuf

Parameters:

m the pixbuf to draw on
x x-start of box
y y-start of box
width width of box
height height of box
red value of red channel
green value of green channel
blue value of blue channel

Returns:

FALSE

int ho_pixbuf_draw_horizontal_scale (ho_pixbuf * m, const int x1, const int y1, const int length, const int step, const unsigned char red, const unsigned char green, const unsigned char blue)

draw a scale line from x1,y1

Parameters:

m a ho_pixbuf
x1 x cordinate of start point
y1 y cordinate of start point
length length of scale line
step size of scale marks
red value of red channel
green value of green channel
blue value of blue channel

Returns:

FALSE

int ho_pixbuf_draw_vertical_scale (ho_pixbuf * m, const int x1, const int y1, const int length, const int step, const unsigned char red, const unsigned char green, const unsigned char blue)

draw a scale line from x1,y1

Parameters:

m a ho_pixbuf
x1 x cordinate of start point
y1 y cordinate of start point
length length of scale line
step size of scale marks
red value of red channel
green value of green channel
blue value of blue channel

Returns:

FALSE

int ho_pixbuf_draw_grid (ho_pixbuf * m, const int size, const int step, const unsigned char red, const unsigned char green, const unsigned char blue)

draw a grid

Parameters:

m a ho_pixbuf
size size of grid boxes
step size of scale marks
red value of red channel
green value of green channel
blue value of blue channel

Returns:

FALSE

int ho_pixbuf_draw_bitmap (ho_pixbuf * m, const ho_bitmap * bit_in, const unsigned char red, const unsigned char green, const unsigned char blue, const unsigned char alpha)

draw a bitmap

Parameters:

m a ho_pixbuf
bit_in the bitmap to draw on the pixbuf
red value of red channel
green value of green channel
blue value of blue channel
alpha value of alpha channel

Returns:

FALSE

int ho_pixbuf_draw_rgb_bitmap (ho_pixbuf * m, const ho_bitmap * bit_in_red, const ho_bitmap * bit_in_green, const ho_bitmap * bit_in_blue)

draw RGB bitmap

Parameters:

m a ho_pixbuf
bit_in_red the bitmap to draw on the pixbuf red channel
bit_in_green the bitmap to draw on the pixbuf green channel
bit_in_blue the bitmap to draw on the pixbuf blue channel

Returns:

FALSE

int ho_pixbuf_draw_rgb_pixbufs (ho_pixbuf * m, const ho_pixbuf * bit_in_red, const ho_pixbuf * bit_in_green, const ho_pixbuf * bit_in_blue)

draw RGB pixbufs

Parameters:

m a ho_pixbuf
bit_in_red the grey pixbuf to draw on the pixbuf red channel
bit_in_green the grey pixbuf to draw on the pixbuf green channel
bit_in_blue the grey pixbuf to draw on the pixbuf blue channel

Returns:

FALSE

int ho_pixbuf_draw_bitmap_at (ho_pixbuf * m, const ho_bitmap * bit_in, const int x1, const int y1, const unsigned char red, const unsigned char green, const unsigned char blue, const unsigned char alpha)

draw a bitmap

Parameters:

m a ho_pixbuf
bit_in the bitmap to draw on the pixbuf
x1 x of upper right start of drawing
y1 y of upper right start of drawing
red value of red channel
green value of green channel
blue value of blue channel
alpha value of alpha channel

Returns:

FALSE

ho_pixbuf* ho_pixbuf_pnm_load (const char * filename)

read ho_pixbuf from pnm file 8 or 24 bpp

Parameters:

filename file name of pnm file

Returns:

newly allocated ho_pixbuf

int ho_pixbuf_pnm_save (const ho_pixbuf * pix, const char * filename)

writes ho_pixbuf to pnm file

Parameters:

pix ho_pixbuf 8 or 24 bpp
filename save as file name

Returns:

FALSE

ho_pixbuf* ho_pixbuf_bw_tiff_load (const char * filename)

read ho_pixbuf from a b/w tiff file

Parameters:

filename file name of tiff file

Returns:

newly allocated gray ho_pixbuf

int ho_pixbuf_bw_tiff_save (const ho_pixbuf * pix, const char * filename)

writes ho_pixbuf to a black and white tiff file

Parameters:

pix ho_pixbuf 8 or 24 bpp
filename save as file name

Returns:

FALSE

Author

Generated automatically by Doxygen for libhocr from the source code.