Table of Contents

NAME

QccIMGImageComponent - data structure QccIMGImageComponent and corresponding ICP file format for a single-band image component

SYNOPSIS

#include "libQccPack.h"

int QccIMGImageComponentInitialize(QccIMGImageComponent *image_component);
int QccIMGImageComponentAlloc(QccIMGImageComponent *image_component);
void QccIMGImageComponentFree(QccIMGImageComponent *image_component);
int QccIMGImageComponentPrint(const QccIMGImageComponent *image_component);

int QccIMGImageComponentSetMin(QccIMGImageComponent *image_component);
int QccIMGImageComponentSetMax(QccIMGImageComponent *image_component);
int QccIMGImageComponentSetMaxMin(QccIMGImageComponent *image_component);

int QccIMGImageComponentResize(QccIMGImageComponent *image_component, int num_rows, int num_cols);

DESCRIPTION

QccPack provides data structure QccIMGImageComponent for representing a single-band image component. This image-component structure can be read from and written to ICP-format files, or a QccIMGImageComponent structure can be used without file input or output. Notably, the three-band QccIMGImage(3) structure uses three QccIMGImageComponent structures to represent the luminance/chrominance bands of a full-color image.

The main component of a QccIMGImageComponent structure is a two-dimensional array of floating-point values representing the component's pixels.

DATA STRUCTURE

The QccIMGImageComponent data structure is defined as:

typedef QccMatrix QccIMGImageArray;
typedef struct
{
QccString filename;
QccString magic_num;
int major_version;
int minor_version;
int num_rows;
int num_cols;
double min_val;
double max_val;
QccIMGImageArray image;
} QccIMGImageComponent;

The fields of QccIMGImageComponent are as follows:

filename
The name of the file.
magic_num, major_version, minor_version
The magic number and version of the file.
num_rows, num_cols
The number of rows and columns of the image component.
min_val, max_val
The minimum and maximum pixel values in the image component.
image
The array of pixels.

FILE FORMAT

For reading and writing structures of type QccIMGImageComponent, QccPack provides the ICP file format. This file format starts with an ASCII header followed by binary data. The ASCII header starts with a magic number, and can be followed with any amount of white space (blanks, `\t' (tab), `\n' (newline), `\r' (carriage return)) and/or comments lines (lines starting with "#"). Following this white space, additional ASCII header information is given, separated by blanks and newlines. Binary data follows this ASCII header information. Note: one (and only one) newline must immediately follow the last component of ASCII header information before the start of the binary data.

The ICP file format consists of the following information:

ICPX.X
<white space>
C R
min max
i11 i12...
i21 i22...
.
.
.

where ICP is the magic number, X.X is the version number, <white space> is white space and/or comment lines, C is the number of columns of the image component, R is the number of rows, and min and max give the range of the values of the image component. imn is the pixel for the mth row, nth column of the image. C, R, min, and max are stored in ASCII. The image component itself, imn, is stored as binary floating-point numbers (4 bytes each, MSB first, see QccFileWriteDouble(3) ).

ROUTINES

QccIMGImageComponentInitialize() should be called before any use of a QccIMGImageComponent structure. QccIMGImageComponentInitialize() initializes the fields of image_component to the following values:

filename: NULL string
magic_num: QCCIMGIMAGECOMPONENT_MAGICNUM
major_version, minor_version: initialized to output of QccGetQccPackVersion(3)
num_rows: 0
num_cols: 0
min_val: 0
max_val: 0
image: NULL

QccIMGImageComponentAlloc() allocates storage space for image_component->image. If image_component->image is not NULL, QccIMGImageComponentAlloc() returns immediately without changing the state of any memory allocation. Otherwise, the image_component->image array is allocated. The fields image_component->num_rows and image_component->num_cols must be set prior to calling QccIMGImageComponentAlloc().

QccIMGImageComponentFree() frees the image_component->image array previously allocated by QccIMGImageComponentAlloc().

QccIMGImageComponentPrint() prints the contents of image_component to stdout.

QccIMGImageComponentSetMin() determines the smallest pixel value in image_component->image and sets image_component->min_val to that minimum value.

QccIMGImageComponentSetMax() determines the largest pixel value in image_component->image and sets image_component->max_val to that maximum value.

QccIMGImageComponentSetMaxMin() sets both image_component->max_val and image_component->min_val by calling QccIMGImageComponentSetMax() and QccIMGImageComponentSetMin() in succession.

QccIMGImageComponentResize() calls QccMatrixResize(3) to change the size of image_component to num_rows x num_cols.

RETURN VALUE

These routines return 0 on success, and 1 on failure.

SEE ALSO

QccFileWriteDouble(3) , QccIMGImage(3) , QccPackIMG(3) , QccPack(3)

AUTHOR

Copyright (C) 1997-2021 James E. Fowler


Table of Contents



Get QccPack at SourceForge.net. Fast, secure and Free Open Source software downloads