VCLib Documentation  6.12.2

Pixel Format Conversion and Input/Output

Pixel Format Conversion and Input/Output

Modules

 JPEG Routines
 

Functions

I32 integral_image (image *src, image *dst)
 Computes the Integral Image according to Viola & Jones, 2002. More...
 
I32 fread_image (char *path, image *img)
 Reads Image Content from a Bitmap File (BMP). More...
 
I32 fwrite_image (char *path, image *img)
 Writes Image Content to a Bitmap File (BMP). More...
 
I32 fwrite_image_vector_color (char *path, image *imgVec, I32 maxAngle)
 Writes Vector Image Content to a Color Bitmap File (BMP). More...
 
I32 fread_image_size (char *path, I32 *dx, I32 *dy, I32 *bpp)
 
I32 ImgConvert_I16_U8 (image *Src16, image *Dst)
 Scales and Converts Image Content from 16 to 8 Bits. More...
 
I32 ImgConvert_I32_U8 (image *Src32, image *Dst)
 Scales and Converts Image Content from 32 to 8 Bits. More...
 
I32 vc_assign_component (image *src, image *cmp, I32 component)
 Assigns a Reference to a Component of a Multi-Component Image to an Image Variable. More...
 
I32 get_component (image *src, image *dst, I32 component)
 Copies a Component out of a Multi-Component Image into a Grey Image. More...
 

Detailed Description

Functions in this group convert image data to another representation, for example encoding images to JPEG.

Color image processing functions however, for example functions converting RGB valued pixel information to HSV, can be found at Color Image Processing.

Function Documentation

◆ integral_image()

I32 integral_image ( image src,
image dst 
)

Performs an integral image Computation according to Viola & Jones, 2002. This function works for all box integrals up to a size of 4096x4096 (32bit destination image) or 16x16 (16bit destination image) even if the source image is larger than that. This is achieved by "computing through the overflow" i.e. if U32 is used, the result will still be correct even if several overflows occured, as long as the size of the final integral is less than the number space of U32.

Parameters
srcSource Image Pointer, Type: IMAGE_GREY.
dstDestination Image Pointer, Type: IMAGE_GREY32, IMAGE_GREY16.
Return values
ERR_TYPEif dst image is not of Type IMAGE_GREY32 or IMAGE_GREY16 or src is no Grey Image.
ERR_MEMORYiff Memory could not be allocated.
ERR_NONEon Success.

◆ fread_image()

I32 fread_image ( char *  path,
image img 
)

This function reads the bitmap image (BMP) from the file specified by path and stores it in image variable img. Image types supported are IMAGE_GREY and IMAGE_RGB. BMP images must be stored in 8 Bit grey- or 24 Bit true-color mode. If the type of the file data does not fit the image variable type, the function returns with error code ERR_FORMAT. If the BMP image is larger than the image variable, the image size is truncated to the size of the image variable.

If you want to generate a compatible bitmap file by yourself, e.g. in Gimp, do use the grayscale mode, do not use run length compression (Run-Length encoded), do not write color space information (see: Compatibility Options) and choose the bit depth 24: R8 G8 B8 (see: Advanced Options).

Parameters
pathSource File.
imgDestination Image (allocated) Pointer, Type: IMAGE_GREY or IMAGE_RGB.
Memory Consumption
None.
See also
fwrite_image().
Return values
ERR_TYPEif Output Image is not of Type IMAGE_RGB or IMAGE_GREY.
ERR_OPENif Requested File could not be opened for Reading.
ERR_FSIGNif BMP File Format is not in Microsoft Windows Flavour.
ERR_INCONSif Bitmap Header is not of Type BITMAPINFOHEADER or Pixel Data Offset exceeds Header Size.
ERR_FFMT,ERR_FORMATif Pixel Data is not of 8 for Grey or 24 for RGB Bit Size.
ERR_FFMTif Bitmap Data is compressed.
ERR_NONEon Success.

◆ fwrite_image()

I32 fwrite_image ( char *  path,
image img 
)

This function writes the image defined by image variable img as a bitmap file (BMP) to the file specified by path. Image types supported are IMAGE_GREY and IMAGE_RGB. Images are stored in 8 Bit grey- or 24 Bit true-color mode depending on the type of the image variable.

Parameters
pathThe Destination File.
imgSource Image Pointer, Type: IMAGE_GREY or IMAGE_RGB.
Memory Consumption
None.
See also
fread_image().
Return values
ERR_TYPEif Input Image is not of Type IMAGE_RGB or IMAGE_GREY.
ERR_OPENif Requested File could not be opened for Writing.
ERR_NONEon Success.

◆ fwrite_image_vector_color()

I32 fwrite_image_vector_color ( char *  path,
image imgVec,
I32  maxAngle 
)

This function writes the vector image defined by image variable imgVec as a color bitmap file (BMP) to the file specified by path. While the values at the st component of the imgVec represents the brightness of its pixel, the color represents its ccmp1 component value: Until maxAngle is reached (for example for gradient_3x3() a value of 256 or for gradient_3x3_Thresh() a value of 128), the color cycles through: Red -> Orange -> Yellow -> Green -> Cyan -> Blue -> Violet -> Pink -> Red.

The image is stored in 24 Bit true-color mode.

Note
The image may be very dark, so it may be needed to be lightened up a bit.
Parameters
pathThe Destination File.
imgVecSource Image Pointer, Type: IMAGE_VECTOR.
Memory Consumption
None.
See also
fwrite_image().
Return values
ERR_TYPEif image is not of type IMAGE_VECTOR.
ERR_MEMORYon memory allocation failure.
Returns
any error of the fwrite_image() function.

◆ fread_image_size()

I32 fread_image_size ( char *  path,
I32 dx,
I32 dy,
I32 bpp 
)

Reads Image dimensions from a BMP File.

This function reads the image width and height of a BMP file.

Parameters
pathSource File.
dx,dySize.
bppBits per Pixel: 8 bit is grey/indexed, 24 bit is color.
Return values
ERR_OPENif Requested File could not be opened for Reading.
ERR_FSIGNif BMP File Format is not in Microsoft Windows Flavour.
ERR_INCONSif Bitmap Header is not of Type BITMAPINFOHEADER or Pixel Data Offset exceeds Header Size.
ERR_NONEon Success.

◆ ImgConvert_I16_U8()

I32 ImgConvert_I16_U8 ( image Src16,
image Dst 
)
Parameters
Src16Source Image of Type IMAGE_GREY16.
DstDestination Image of Type IMAGE_GREY.
Returns
Standard Error Code.

◆ ImgConvert_I32_U8()

I32 ImgConvert_I32_U8 ( image Src32,
image Dst 
)

This function scales and converts an image from IMAGE_GREY32 to IMAGE_GREY. The maximum absolute grey value in Src32 is calculated and used for the scaling transformation according to the following formula:

\[ px_\texttt{Dst} = px_\texttt{Src32} \cdot \frac{255}{\textrm{max}_{|\texttt{Src32}|}} \]

The function may be used to display 32 Bit Hough transform images.

Parameters
Src32Source Image of Type IMAGE_GREY32.
DstDestination Image of Type IMAGE_GREY.
Returns
Standard Error Code.

◆ vc_assign_component()

I32 vc_assign_component ( image src,
image coi,
I32  component 
)

The function assigns a reference to a component (e.g. a colour channel) of a multi-component image to an image variable of Type IMAGE_GREY.

Note
Since image data is not copied, changes done to the coi image will operate on the src image's component!
Parameters
srcSource Image (Various Types).
coiReferring Image of Type IMAGE_GREY.
componentNumber of Component (0, 1, 2).
Returns
Standard Error Code.

◆ get_component()

I32 get_component ( image src,
image dst,
I32  component 
)

The function copies a component (e.g. a colour channel) out of a multi-component image into an image of Type IMAGE_GREY.

Parameters
srcSource Image (Various Types).
dstDestination Image of Type IMAGE_GREY.
componentNumber of Component (0, 1, 2).
Returns
Standard Error Code.