Table of Contents
QccIMGImage - data structure QccIMGImage grayscale and color images
#include "libQccPack.h"
int QccIMGImageInitialize(QccIMGImage
*image);
int QccIMGImageGetSize(const QccIMGImage *image, int *num_rows,
int *num_cols);
int QccIMGImageGetSizeYUV(const QccIMGImage *image, int
*num_rows_Y, int *num_cols_Y, int *num_rows_U, int *num_cols_U, int *num_rows_V,
int *num_cols_V);
int QccIMGImageSetSize(QccIMGImage *image, int num_rows,
int num_cols);
int QccIMGImageSetSizeYUV(QccIMGImage *image, int num_rows_Y,
int num_cols_Y, int num_rows_U, int num_cols_U, int num_rows_V, int num_cols_V);
int QccIMGImageAlloc(QccIMGImage *image);
void QccIMGImageFree(QccIMGImage
*image);
int QccIMGImageSetMaxMin(QccIMGImage *image);
int QccIMGImageColor(const
QccIMGImage *image);
QccPack provides data structure QccIMGImage
for representing grayscale and color images. This image-component structure
can be read from and written to several image file formats (see "IMAGE
TYPES" below).
A QccIMGImage structure is essentially a collection of three
image components: a luminance component, and two chrominance components.
These three components are each stored in a QccIMGImageComponent(3)
structure.
In the case of a grayscale image, only the luminance component holds data;
the two chrominance components are empty.
The QccIMGImage
data structure is defined as:
typedef struct
{
int image_type;
QccString filename;
QccIMGImageComponent Y;
QccIMGImageComponent
U;
QccIMGImageComponent V;
} QccIMGImage;
The fields of QccIMGImage
are as follows:
- image_type
- The type of the image.
- filename
- The name of
the file.
- Y
- The luminance component.
- U, V
- The two chrominance components.
The QccIMGImage can be read from or written to a variety
of image file formats. The field image_type in the QccIMGImage structure
denotes the type of the image and can be one of the following:
A color image associated with the PPM file format (see ppm(5)
). Although
the PPM file format stores a color image as red, green, blue (RGB) components,
QccIMGImageRGBtoYUV(3)
is used to convert RGB to luminance/chrominance
(YUV) color space upon file reading, or QccIMGImageYUVtoRGB(3)
upon file
writing, so that the three components are stored as YUV within the QccIMGImage
structure. The RGB pixels in a PPM file are in the range 0 to 255; the
corresponding YUV values are such that Y is in the range 0 to 255, while
U and V are approximately in the range -111 to 111 for U and -157 to 157
for V.
A grayscale image associated with the PGM file format
(see pgm (5)
). The grayscale array associated with the PGM file is stored
in the luminance component of the QccIMGImage structure (i.e., the Y field),
while the chrominance components (U and V) are empty. The grayscale pixel
values lie in the range 0 to 255.
A binary (black/white)
image associated with the PBM file format (see pbm(5)
). The bilevel array
associated with the PBM file is stored in the luminance component of the
QccIMGImage structure (i.e., the Y field), while the chrominance components
(U and V) are empty. Note that, while the PBM file format dictates that
a pixel value of 1 is black and 0 is white, within the QccIMGImage structure,
the opposite convention is used, i.e., 0 is black and 1 is white.
A grayscale image associated with the ICP file format for QccIMGImageComponent
structure for a single image component. The single component is considered
to be a grayscale image and is stored in the luminance component of the
QccIMGImage structure (i.e., the Y field), while the chrominance components
(U and V) are empty.
QccIMGImageInitialize() should be called
before any use of a QccIMGImage structure. QccIMGImageInitialize() initializes
the fields of image to the following values:
image_type: QCCIMGTYPE_UNKNOWN
filename: NULL string
Additionally, QccIMGImageComponentInitialize(3)
is called for each of the three Y, U, and V image-component fields.
QccIMGImageGetSize()
returns the number of rows and number of columns of image in num_rows
and num_cols, respectively. In essence, it is assumed that image is not
color, so the image size is derived from the Y component of image.
QccIMGImageGetSizeYUV()
returns the size of each of the Y, U, and V image components. In essence,
image is assumed to be color, so the sizes are derived from each of the
respective QccIMGImageComponent structues.
QccIMGImageSetSize() sets the
image size. If the image is color (as indicated by QccIMGImageColor() returning
nonzero), then the size of all three components are set to the specified
number of rows and columns. Otherwise, for a grayscale image, only the
Y component is set to the specified size, while the U and V components
are set to size 0 x 0.
QccIMGImageSetSizeYUV() sets each of the three image
components to the indicated sizes, which need not all be identical.
QccIMGImageAlloc()
calls QccIMGImageComponentAlloc(3)
to allocate storage space for each
of the three image components in image. The size of the image must be set
via a call to QccIMGImageSetSize() or QccIMGImageSetSizeYUV() prior to
calling QccIMGImageAlloc().
QccIMGImageFree() frees the three image components
via three calls to QccIMGImageComponentFree(3)
.
QccIMGImageSetMaxMin()
sets the mimimum and maximum values in each of the three image components
via three calls to QccIMGImageComponentSetMaxMin(3)
.
QccIMGImageColor()
returns 1 if the image is color (i.e., if image->image_type is QCCIMGTYPE_PPM),
and 0 otherwise.
These routines return 0 on success, and
1 on failure.
The PPM, PGM, and PBM are popular image file formats
that are read and written by a number of applications. They belong to the
PNM family of file applications which can be generated and manipulated
with the open-source Netpbm package, http://netpbm.sourceforge.net.
The routines
in QccPack can handle files from this family in both their "raw" (binary)
and "plain" (ASCII) variants.
QccIMGImageComponent(3)
, QccIMGImageRGBtoYUV(3)
,
QccIMGImageYUVtoRGB(3)
, QccIMGImageRead(3)
, QccIMGImageWrite(3)
, pnm(5)
,
ppm(5)
, pgm(5)
, pbm(5)
, QccIMGImage(3)
, QccPackIMG(3)
, QccPack(3)
Copyright (C) 1997-2021 James E. Fowler
Table of Contents