Intel® Image Processing Library Reference Manual Copyright © 1997-2000, Intel Corporation All Rights Reserved Issued in U.S.A.
How to Use This Online Manual Click to hide or show subtopics when the bookmarks are shown. Click to go to the previous page. Double-click to jump to a topic when the bookmarks are shown. Click to go to the next page. Click to display bookmarks. Click to go to the last page. Click to display thumbnails. Click to return back to the previous view. Use this button when you need to go back after using the jump button (see below). Click to close bookmark or thumbnail view.
® Intel Image Processing Library Reference Manual Document Number: 663791-005 World Wide Web: http://developer.intel.com Revision Revision History Date -001 First release. 07/97 -002 Documents Image Processing Library release 2.0 06/98 -003 Added the functions MpyRCPack2D, Remap, DecimateExt, Scale, ScaleFP, ColorTwistFP, MinMaxFP, and the compare functions. 01/99 -004 Documents Image Processing Library release 2.2 02/00 -005 Documents Image Processing Library release 2.
This documentation as well as the software described in it is furnished under license and may only be used or copied in accordance with the terms of the license. The information in this document is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Intel Corporation.
Contents Chapter 1 Overview About This Software........................................................... 1-1 Hardware and Software Requirements.......................... 1-1 About This Manual ............................................................. 1-2 Manual Organization ..................................................... 1-2 Function Descriptions.................................................... 1-4 Audience for This Manual.............................................. 1-4 Online Version.......
® Intel Image Processing Library Reference Manual Handling Overflow and Underflow ................................. 2-8 In-Place and Out-of-Place Operations ........................... 2-8 Image Tiling ....................................................................... 2-8 Tile Size ........................................................................ 2-9 Call-backs...................................................................... 2-9 ROI and Tiling .............................................
Contents AllocateImage ............................................................... 4-13 AllocateImageFP ........................................................... 4-13 DeallocateImage ........................................................... 4-15 CloneImage................................................................... 4-15 Deallocate ..................................................................... 4-16 CheckImageHeader ......................................................
® Intel Image Processing Library Reference Manual PutPixel ......................................................................... 4-38 GetPixel......................................................................... 4-38 Scale ............................................................................. 4-40 ScaleFP......................................................................... 4-41 NoiseImage ................................................................... 4-42 NoiseUniformInit .........
Contents Multiply.......................................................................... 5-8 MultiplyScale ................................................................. 5-9 Monadic Logical Operations............................................... 5-10 LShiftS .......................................................................... 5-10 RShiftS.......................................................................... 5-11 Not .........................................................................
® Intel Image Processing Library Reference Manual Convolve2D................................................................... 6-8 Convolve2DFP .............................................................. 6-8 ConvolveSep2D............................................................. 6-11 ConvolveSep2DFP ........................................................ 6-11 FixedFilter...................................................................... 6-12 Non-linear Filters...................................
Contents Conversion of Absolute Colors to and from Palette Colors. 9-7 Conversion from Color to Gray Scale................................. 9-8 ColorToGray.................................................................. 9-8 Conversion from Gray Scale to Color (Pseudo-color) ........ 9-9 GrayToColor.................................................................. 9-9 Conversion of Color Models............................................... 9-10 Data ranges in the HLS and HSV Color Models ............
® Intel Image Processing Library Reference Manual Lookup Table (LUT) and Histogram Operations................. 10-5 The IplLUT Structure ..................................................... 10-5 ContrastStretch ............................................................. 10-7 ComputeHisto................................................................ 10-9 HistoEqualize ................................................................ 10-10 Comparing Images................................................
Contents RotateCenter................................................................. 11-13 Mirror............................................................................. 11-14 Warping ............................................................................. 11-15 Shear ............................................................................ 11-16 WarpAffine .................................................................... 11-17 GetAffineBound...............................................
® Intel Image Processing Library Reference Manual NormalizedSpatialMoment............................................. 12-10 NormalizedCentralMoment ............................................ 12-11 Cross-Correlation ............................................................... 12-12 NormCrossCorr ............................................................. 12-13 Minimum and Maximum ..................................................... 12-14 MinMaxFP ...................................................
Contents Tables Table 2-1 Data Ordering .................................................... 2-3 Table 3-1 iplError() Status Codes....................................... 3-10 Table 4-1 Image Creation, Data Exchange and Windows DIB Functions........................................ 4-1 Table 4-2 Image Header Attributes .................................... 4-4 Table 5-1 Image Arithmetic and Logical Operations........... 5-1 Table 5-2 Types of Image Compositing Operations ...........
® Intel Image Processing Library Reference Manual Table A-4 Image Attributes and Modes of Alpha-Blending Functions ................................... A-4 Table A-5 Image Attributes and Modes of Filtering Functions............................................... A-4 Table A-6 Image Attributes and Modes of Fourier and DCT Functions ................................. A-4 Table A-7 Image Attributes and Modes of Morphological Operations ...................................
Contents Examples Example 3-1 Error Functions ............................................. 3-13 Example 3-2 Output for the Error Function Program (IPL_ErrModeParent).......................................... 3-15 Example 3-3 Output for the Error Function Program (IPL_ErrModeParent).......................................... 3-15 Example 3-4 A Simple Error Handler ................................. 3-17 Example 4-1 Creating and Deleting an Image Header .......
® Intel Image Processing Library Reference Manual Example 11-2 Rotating an Image....................................... 11-11 Example 11-3 Using Macro Definition to Rotate an Image ............................................................ 11-14 Example 11-4 Re-mapping an Image................................. 11-29 Example 12-1 Computing the Norm of Pixel Values........... 12-4 Example 13-1 Image Channel Values Processing by User-Defined Function ..................................
Overview 1 This manual describes the structure, operation and functions of the Intel Image Processing Library. This library supports many functions whose performance can be significantly enhanced on processors with the MMX technology, as well as on Intel Pentium III processors. The manual describes the library’s data and execution architecture and provides detailed descriptions of the library functions. This chapter introduces the Image Processing Library and explains the organization of this manual.
1 ® Intel Image Processing Library Reference Manual About This Manual This manual provides a background of the image and execution architecture of the Image Processing Library as well as detailed descriptions of the library functions. The functions are combined in groups by their functionality. Each group of functions is described in a separate chapter (chapters 3 through 14). Manual Organization This manual contains fourteen chapters: 1-2 Chapter 1 “Overview.
1 Overview Chapter 6 “Image Filtering.” Describes linear and nonlinear filtering operations that can be applied to images. Chapter 7 “Linear Image Transforms.” Describes the fast Fourier transform (FFT) and Discrete Cosine Transform (DCT) implemented in the library. Chapter 8 “Morphological Operations.” Describes the functions that perform erosion, dilation, and their combinations. Chapter 9 “Color Space Conversion.
1 ® Intel Image Processing Library Reference Manual The manual also includes a Glossary, Bibliography, and Index, as well as two appendixes that list supported image attributes and operation modes and describe interpolation algorithms used in the library. Function Descriptions In Chapters 3 through 14, each function is introduced by name (without the ipl prefix) and a brief description of its purpose.
1 Overview Online Version This manual is available in an online hypertext format. To obtain a hard copy of the manual, print the online file using the printing capability of Adobe* Acrobat*, the tool used for the online presentation of the document. Sources of Related Information For more information about computer graphics concepts and objects, refer to the books and materials listed in the Bibliography.
1 ® Intel Image Processing Library Reference Manual Naming Conventions The following data type conventions are used by the library: • Constant identifiers are in uppercase; for example, IPL_SIDE_LEFT. • All constant identifiers have the IPL prefix. • All function names have the ipl prefix. In code examples, you can distinguish the library interface functions from the application functions by this prefix. NOTE. In this manual, the ipl prefix in function names is always used in the code examples.
1 Overview target only; for example, the functions Multiply or RealFft2D, respectively. mod The mod field is optional and indicates a modification to the core functionality of a function. For example, in the name iplAlphaCompositeC(), C indicates that this function is using constant alpha values.
This page is left blank for double-sided printing This page is left blank for double-sided printing
Image Architecture 2 This chapter describes the data and execution architecture of the Image Processing Library. It introduces the library’s color models, data types, coordinate systems, regions of interest, data alignment, in-place and notin-place execution, and image tiling. Data Architecture Any image in the Image Processing Library has a header that describes the image as a list of attributes and pointers to the data associated with the image.
2 ® Intel Image Processing Library Reference Manual The multi-spectral image (MSI) model is used for general purpose images. It is used for any kind of multi-spectral data and any kind of image. For example, the Fourier transform operation writes transform coefficients of color or monochrome images to this modelone channel for each channel in the input. The result can be viewed as an MSI image.
2 Image Architecture The Sequence and Order of Color Channels Channel sequence corresponds to the order of the color channels in absolute color images. For example, in an RGB image the channels could be stored in the sequence RGB or in the sequence BGR. NOTE. For functions that perform color space conversions or image format conversions, the channel sequence information is required and therefore must be provided. All other functions ignore channel sequence.
2 ® Intel Image Processing Library Reference Manual Coordinate Systems Two coordinate systems are supported by the library’s image format. • The origin of the image is in the top left corner, the x values increase from left to right, and y values increase from top to bottom. • The origin of the image is in the bottom left corner, the x values increase from left to right, and y values increase from the bottom to the top.
Image Architecture 2 applicable ROIs. For example, if an image has both types of ROI and a COI, operations are performed only on the values of this COI, and only for those pixels that belong to the intersection of mask ROI and rectangular ROI. Both the source and destination image can have a region of interest. In such cases, operations will be performed on the intersection of the ROIs. Thus, an image region of interest specifies some part of an image or the entire image.
2 ® Intel Image Processing Library Reference Manual If one image (input or output) has one channel in its COI and another image (input or output) has more than one channel included in its COI, an error will occur.
Image Architecture 2 Alpha (Opacity) Channel In addition to the color channels, an image can have one alpha channel, also known as an opacity channel, which is mainly used for image compositing operations (see “Image Compositing Based on Opacity” in Chapter 5). The alpha channel must be the last channel in the image. The interpretation of operations on the alpha channel is usually different from that for color channels.
2 ® Intel Image Processing Library Reference Manual Execution Architecture Handling Overflow and Underflow Overflow and underflow are handled in each image processing function. The Image Processing Library uses saturation to prevent the pixel values from potential overflow or underflow. Thus, when an overflow of a pixel value is about to happen, this value is clamped to the maximum permissible value (for example, 255 for an unsigned byte).
2 Image Architecture This section gives a short overview of image tiling in the Image Processing Library. In Chapter 4 you will find more information about tiling, namely, the descriptions of the TileInfo structure, the imageID parameter, and the functions CreateTileInfo, SetTileInfo, and DeleteTileInfo. Tile Size In the Image Processing Library, all tiles must be of the same size, including those on the edge of an image.
2 ® Intel Image Processing Library Reference Manual tile number, not pixel number, and count from the origin at (0,0); mode is one of the following: IPL_GET_TILE_TO_READ get a tile for reading; the tile data must be returned in img->tileInfo->tileData and must not be changed; IPL_GET_TILE_TO_WRITE get a tile for writing; the tile data must be returned in img->tileInfo->tileData and may be changed; changes will be reflected in the image; IPL_RELEASE_TILE release tile; commit writes.
Error Handling 3 This chapter describes the error handling facility of the Image Processing Library. The library functions report a variety of errors including bad arguments and out-of-memory conditions. Most functions in the library do not return any status code. When a function detects an error, it sets the error status code by calling iplSetErrStatus(). This allows the error handling mechanism to work separately from the normal flow of the image processing code.
3 ® Intel Image Processing Library Reference Manual reporting these exceptions. A floating-point library is needed if a processor that handles floating-point is not present. You can attach an exception handler using an underlying floating-point library for your application, if your system supports such a library. Error-handling Functions The following sections describe the error functions in the Image Processing Library. Error Performs basic error handling.
3 Error Handling To simplify the coding for error checking and reporting, the error handling system of the Image Processing Library supports a set of error macros. See “Error Macros” for a detailed description of the error handling macros. The iplError() function calls the default error reporting function. You can change the default error reporting function by calling iplRedirectError(). For more information, see the description of iplRedirectError.
3 ® Intel Image Processing Library Reference Manual GetErrMode SetErrMode Gets and sets the error modes that describe how an error is processed. #define IPL_ErrModeLeaf 0 #define IPL_ErrModeParent 1 #define IPL_ErrModeSilent 2 int iplGetErrMode(); void iplSetErrMode(int errMode); errMode Indicates how errors will be processed. The possible values for errMode are IPL_ErrModeLeaf, IPL_ErrModeParent, or IPL_ErrModeSilent. Discussion NOTE.
3 Error Handling If you specify IPL_ErrModeParent, errors are processed in the “parents” of the function call tree. When iplError() is called as the result of detecting an error, an error message will print, but the program will not terminate. Each time a function calls another function, it must check to see if an error has occurred. When an error occurs, the function should call iplError() specifying IPL_StsBackTrace, and then return.
3 ® Intel Image Processing Library Reference Manual Discussion The function iplErrorStr() returns a short string describing status. Use this function to produce error messages for users. The returned pointer is a pointer to an internal static buffer that may be overwritten on the next call to iplErrorStr(). RedirectError Assigns a new error handler to call when an error occurs.
3 Error Handling NullDevReport StdErrReport GuiBoxReport Predefined error-handling functions that send error messages to different output destinations.
3 ® Intel Image Processing Library Reference Manual Discussion You can use these predefined functions as error handlers to redirect error reporting in your application to a different output destination. The iplNulDevReport() function directs error reporting to the NULL device, that is, outputs no error messages. The iplStdErrReport() function is used in programs running in the console mode, it outputs error messages to the console.
3 Error Handling Error Macros The error macros associated with the iplError() function are described below.
3 ® Intel Image Processing Library Reference Manual The IPL_ERROR() macro simply calls the iplError() function by default. This macro is used by other error macros. By changing IPL_ERROR() you can modify the error reporting behavior without changing a single line of source code. The IPL_RSTERR() macro resets the error status to IPL_StsOk, thus clearing any error condition. This macro should be used by an application when it decides to ignore an error condition.
3 Error Handling Table 3-1 iplError() Status Codes (continued) Status Code Value Description IPL_StsNoMem -4 A function attempted to allocate memory using malloc() or a related function and was unsuccessful. The message context indicates the intended use of the memory. IPL_StsBadArg -5 One of the arguments passed to the function is invalid. The message context indicates which argument and why.
3 ® Intel Image Processing Library Reference Manual Table 3-1 iplError() Status Codes (continued) Status Code Value Description IPL_BadOrigin -20 Incorrect data origin value in the image header. IPL_BadAlign -21 Incorrect data alignment value in the image header. IPL_BadCallBack -22 Null pointer to callback function. IPL_BadTileSize -23 Incorrect size of the tile. IPL_BadCOI -24 Incorrect COI of the image. IPL_BadROISize -25 Incorrect size of ROI in the image header.
3 Error Handling Error Handling Example The following example describes the default error handling for a console application. In the example program, test.c, assume that the function libFuncB() represents a library function such as ipl?AddS(), and the function libFuncD() represents a function that is called internally to the library. In this scenario, main() and appFuncA() represent application code. The value of the error mode is set to IPL_ErrModeParent.
3 ® Intel Image Processing Library Reference Manual Example 3-1 Error Functions (continued) /* library function */ void libFuncB(double a, int order) { float *vec; if (order > 31) { IPL_ERROR(IPL_StsBadArg, "libFuncB", "order must be less than or equal to 31"); return; } if ((vec = libFuncD(a, order)) == NULL) { IPL_ERRCHK("libFuncB", "compute using a"); return; } /* code to do some real work goes here */ free(vec); } // next: library function called internally double *libFuncD(double a, int order) { d
Error Handling 3 Example 3-2 Output for the Error Function Program (IPL_ErrModeParent) IPL Library Error: Invalid argument in function libFuncB: order must be less than or equal to 31 called from function appFuncA: compute using order2 called from function main: compute something If the program runs with the IPL_ErrModeLeaf option instead of IPL_ErrModeParent, only the first line of the above output is produced before the program terminated.
3 ® Intel Image Processing Library Reference Manual application is running under a Windows system or you can choose to send error messages to a special log file. There are two methods of adding your own error handler. In the first method, you can replace the iplError() function or the complete error handling library with your own code. Note that this method can only be used at link time. In the second method, you can use the iplRedirectError() function to replace the error handler at run time.
Error Handling 3 Example 3-4 A Simple Error Handler IPLStatus ownError(IPLStatus status, const char *func, const char *context, const char *file, int line); { fprintf(stderr, "IPL Library error: %s, ", iplErrorStr(status)); fprintf(stderr, "function %s, ", func ? func : ""); if (line > 0) fprintf(stderr, "line %d, ", line); if (file != NULL) fprintf(stderr, "file %s, ", file); if (context) fprintf(stderr, "context %s\n", context); IplSetErrStatus(status); exit(1); } main () { extern IPLErrorCallB
This page is left blank for double-sided printing This page is left blank for double-sided printing
4 Image Creation and Access This chapter describes the functions that provide the following functionalities: • Creating and accessing attributes of images (both tiled and non-tiled) • Allocating memory for data of required type (see also the functions CreateConvKernel in Chapter 6 and CreateColorTwist in Chapter 9) • Setting, copying, exchanging, and scaling image data. • Generating and adding noise to image data. • Working in the Windows DIB (device-independent bitmap) environment.
4 ® Intel Image Processing Library Reference Manual Table 4-1 Image Creation, Data Exchange and Windows DIB Environment Functions (continued) Group Function Name Description Creating Images iplSetROI Sets a region of interest for an image. (cont-d) iplSetBorderMode Sets the mode for handling the border pixels. iplCreateTileInfo Creates the IplTileInfo structure. iplSetTileInfo Sets the tiling information. iplDeleteTileInfo Deletes the IplTileInfo structure.
4 Image Creation and Access Table 4-1 Image Creation, Data Exchange and Windows DIB Environment Functions (continued) Group Data Scaling Noise Generation Windows DIB Function Name Description iplExchange Exchanges image data between two images. iplConvert Converts images based on the input and output image requirements. iplScale Scales image data from one data type to another, mapping the whole data range of the input data type to the whole range of output data type.
4 ® Intel Image Processing Library Reference Manual Image Header and Attributes The Image Processing Library functions operate on a single format for images in memory. This format consists of a header of type IPLImage containing the information for all image attributes. The header also contains a pointer to the image data. (See the attributes description in Chapter 2, section “Data Architecture.”) The values that these attributes can assume are listed in Table 4-2.
4 Image Creation and Access Table 4-2 Image Header Attributes (continued) Corresponding DIB Attribute Description Value Channel sequence 4-character string. Can be “G”, “GRAY”, “BGR”, “BGRA”, “RGB”, “RGBA”, “HSV”, “HLS”, “XYZ”, “YUV”, “YCr”, “YCC”, or “LUV”. Not supported (implicitly BGR for RGB images.
4 ® Intel Image Processing Library Reference Manual Figure 4-1 presents a graphical depiction of an RGB image with a rectangular ROI and a COI.
4 Image Creation and Access The C language definition for the IPLImage structure is given below. IplImage Structure Definition typedef struct _IplImage { IPL.
4 ® Intel Image Processing Library Reference Manual Tiling Fields in the IplImage Structure Image tiling in the Image Processing Library was described in Chapter 2. The following fields from the IplImage structure are used in tiled images: struct IplImage { ... void* imageId; IplTileInfo *tileInfo; ... } The imageId field can be used by the application, and is ignored by the library. The tileInfo field contains information on tiling. It is described in the next section.
4 Image Creation and Access Creating Images There are several ways of creating a new image: • Construct an IplImage header by setting the attributes to appropriate values, then call the function iplAllocateImage() to allocate memory for the image or set the image data pointer to image data (in a compatible format) that already exists.
4 4-10 ® Intel Image Processing Library Reference Manual colorModel A four-character string describing the color model: “RGB”, “GRAY”, “HLS” etc. channelSeq The sequence of color channels; can be one of the following: “G”, “GRAY”, “BGR”, “BGRA”, “RGB”, “RGBA”, “HSV”, “HLS”, “XYZ”, “YUV”, “YCr”, “YCC”, “LUV”. The library uses this information only for image type conversions of known image channel formats. dataOrder IPL_DATA_ORDER_PIXEL or IPL_DATA_ORDER_PLANE. origin The origin of the image.
Image Creation and Access 4 Discussion The function iplCreateImageHeader() creates an IplImage header according to the specified attributes; see Example 4.1. The image data pointer is set to NULL; no memory for image data is allocated.
4 ® Intel Image Processing Library Reference Manual The mask region of interest specified by the maskROI pointer is discussed in the section Image Regions of Interest (Chapter 2). The intersection of aligned rectangular ROI(s) and maskROI(s) for all source images and the destination image forms the actual region to be processed.
4 Image Creation and Access AllocateImage, AllocateImageFP Allocates memory for image data according to the specified header. void iplAllocateImage(IplImage* image, int doFill, int fillValue); void iplAllocateImageFP(IplImage* image, int doFill, float fillValue); image An image header with a NULL image data pointer. The pointer will be set to newly allocated image data memory after calling this function. doFill A flag: if zero, indicates that the pixel data should not be initialized by fillValue.
4 ® Intel Image Processing Library Reference Manual Example 4-2 Allocating and Deallocating the Image Data int example42( void ) { IplImage img; char colorModel[4] = "RGB"; char channelSeq[4] = "BGR"; img.nSize = sizeof( IplImage ); img.nChannels = 3; // number of channels img.alphaChannel = 0; // no alpha channel img.depth = IPL_DEPTH_16U; // data of ushort type img.dataOrder = IPL_DATA_ORDER_PIXEL; img.origin = IPL_ORIGIN_TL; // top left img.align = IPL_ALIGN_QWORD; // align img.width = 100; img.
4 Image Creation and Access DeallocateImage Deallocates (frees) memory for image data pointed to in the image header. void iplDeallocateImage(IplImage* image) image An image header with a pointer to the allocated image data memory. The image data pointer will be set to NULL after this function executes. Discussion The function iplDeallocateImage() is used to free image data memory pointed to by the imageData member of the image header.
4 ® Intel Image Processing Library Reference Manual Deallocate Deallocates or frees memory for image header or data or mask ROI or rectangular ROI or all four. void iplDeallocate (IplImage* image, int flag) image An image header with a pointer to allocated image data memory. The image data pointer will be set to NULL after this function executes. flag Flag indicating what memory area to free: IPL_IMAGE_HEADER Free header structure. IPL_IMAGE_IMAGE Free image data, set pointer to NULL.
4 Image Creation and Access CheckImageHeader Validates field values of an existing image header structure. IPLStatus iplCheckImageHeader ( const IplImage* hdr ) hdr Pointer to an image header structure Discussion The function iplCheckImageHeader() checks whether the IplImage header structure of an image has valid field values, and returns the corresponding status code. This function works on the assumption that the referenced image contains non-empty data.
4 ® Intel Image Processing Library Reference Manual IPL_BadCallBack Indicates an error condition if the image is tiled but the call-back function is not set in the _IplTileInfo structure. IPL_BadTileSize Indicates an error condition if a tiled image has tile sizes not multiple of 8. IPL_BadCOI Indicates an error condition if an image with ROI has incorrect coi field value in the _IplROI structure (that is, coi is negative or greater than nChannels).
Image Creation and Access 4 Figure 4-2 illustrates an example of the test image generated by the iplCreateImageJaehne() function. These test images can be effectively used when you need to visualize and interpret the results of applying filtering functions, similarly to what is proposed in [Jaehne].
4 ® Intel Image Processing Library Reference Manual Setting Regions of Interest To set a region of interest, the function iplSetROI() uses a ROI structure IplROI presented below. The IplROI member of the image header must point to this IplROI structure to be effective. This can be done by a simple assignment. The application may choose to construct the ROI structure explicitly without the use of the function.
4 Image Creation and Access CreateROI Allocates and sets the region of interest (ROI) structure. IplROI* iplCreateROI(int coi, int xOffset, int yOffset, int width, int height); coi The channel of interest. It can be set to 0 (for all channels) or to a specific channel number. xOffset, yOffset The offsets from the origin of the rectangular region. width, height The size of the rectangular region.
4 ® Intel Image Processing Library Reference Manual Discussion The function iplDeleteROI() deallocates a ROI structure previously created by iplCreateROI(). SetROI Sets the region of interest (ROI) structure. void iplSetROI(IplROI* roi, int coi, int xOffset, int yOffset, int width, int height); roi The pointer to the ROI structure to modify in the original image. coi The channel of interest in the original image. It can be set to 0 (for all channels) or to a specific channel number.
4 Image Creation and Access Image Borders and Image Tiling Many neighborhood operators need intensity values for pixels that lie outside the image, that is, outside the borders of the image. For example, a 3 by 3 filter, when operating on the first row of an image, needs to assume pixel values of the preceding (non-existent) row. A larger filter will require more rows from the border. These border issues therefore exist at the top and bottom, left and right sides, and the four corners of the image.
4 ® Intel Image Processing Library Reference Manual IPL_BORDER_WRAP border The required border rows or columns are taken from the opposite side of the image. The side that this function is called for. Can be an OR of one or more of the following four sides of an image: IPL_SIDE_TOP Top side. IPL_SIDE_BOTTTOM Bottom side. IPL_SIDE_LEFT Left side. IPL_SIDE_RIGHT Right side. IPL_SIDE_ALL All sides. The top side is also used to define all border pixels in the top left and right corners.
4 Image Creation and Access Example 4-3 Setting the Border Mode for an Image int example43( void ) { IplImage *imgh = iplCreateImageHeader( 3,0,IPL_DEPTH_8U, "RGB", "BGR", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_QWORD, 100, 150, NULL, NULL, NULL, NULL); if( NULL == imgh ) return 0; iplSetBorderMode( imgh, IPL_BORDER_REPLICATE, IPL_SIDE_TOP| IPL_SIDE_BOTTOM | IPL_SIDE_LEFT | IPL_SIDE_RIGHT, 0 ); iplDeallocate( imgh, IPL_IMAGE_HEADER ); return Ipl_StsOk == iplGetErrStatus(); } CreateTileInfo Creates
4 ® Intel Image Processing Library Reference Manual SetTileInfo Sets the IplTileInfo structure fields. void iplSetTileInfo(IplTileInfo* tileInfo, IplCallBack callBack, void* id, int width, int height); tileInfo The pointer to the IplTileInfo structure. callBack The call-back function. id The image ID (for application use). width, height The tile sizes. Discussion This function sets attributes for an existing IplTileInfo structure. DeleteTileInfo Deletes the IplTileInfo structure.
4 Image Creation and Access Memory Allocation Functions Functions of the ipl?Malloc() group allocate aligned memory blocks for the image data. The size of allocated memory is specified by the size parameter. The “?” in ipl?Malloc() stands for w, i, s, or d; these letters indicate the data type in the function names as follows: iplMalloc() byte iplwMalloc() 16-bit word ipliMalloc() 32-bit double word iplsMalloc() 4-byte single floating-point element ipldMalloc() 8-byte double floating-point element NOTE.
4 ® Intel Image Processing Library Reference Manual wMalloc Allocates memory aligned to an 8-byte boundary for 16bit words. short* iplwMalloc(int size); size Size in words (16 bits) of memory block to allocate. Discussion The iplwMalloc() function allocates memory block aligned to an 8-byte boundary for 16-bit words. To free this memory, use iplFree(). Return Value The function returns a pointer to an aligned memory block. If no memory is available in the system, then the NULL value is returned.
4 Image Creation and Access Return Value The function returns a pointer to an aligned memory block. If no memory is available in the system, then the NULL value is returned. sMalloc Allocates memory aligned to an 8-byte boundary for floating-point elements. float * iplsMalloc(int size); size Size in float elements (4 bytes) of memory block to allocate. Discussion The iplsMalloc() function allocates memory block aligned to an 8-byte boundary for floating-point elements.
4 ® Intel Image Processing Library Reference Manual dMalloc Allocates memory aligned to an 8-byte boundary for double floating-point elements. double* ipldMalloc(int size); Size in double elements (8 bytes) of memory block to allocate. size Discussion The ipldMalloc() function allocates memory block aligned to an 8-byte boundary for double floating-point elements. To free this memory, use iplFree(). Return Value The function returns a pointer to an aligned memory block.
4 Image Creation and Access Discussion The iplFree() function frees the aligned memory block allocated by one of the functions iplMalloc(), iplwMalloc(), ipliMalloc(), iplsMalloc(), or ipldMalloc(). NOTE. The function iplFree() cannot be used to free memory allocated by standard functions like malloc() or calloc().
4 ® Intel Image Processing Library Reference Manual depth lower than the fillVallue, the fillValue is saturated when assigned to pixel. If an ROI is specified, only that ROI is filled.
Image Creation and Access 4 headers must be properly constructed and image data for both images must be allocated; see Example 4-5. The following constraints apply to the copying: • The bit depth per channel of the source image should be equal to that of the resultant image. • The number of channels of interest in the source image should be equal to the number of channels of interest in the resultant image; that is, either the source coi = the resultant coi = 0 or both cois are nonzero.
4 ® Intel Image Processing Library Reference Manual Example 4-5 Copying Image Pixel Values int example45( void ) { IplImage *imga, *imgb; __try { imga = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_QWORD, 100, 150, NULL, NULL, NULL, NULL); if( NULL == imga ) return 0; imgb = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_QWORD, 100, 150, NULL, NULL, NULL, NULL); if( NULL == imgb ) return
4 Image Creation and Access Exchange Exchanges image data between two images. void iplExchange(IplImage* ImageA, IplImage* ImageB); ImageA The first image. ImageB The second image. Discussion The function iplExchange() exchanges image data between two images, the first and the second. The image headers must be properly constructed before calling this function, and image data for both images must be allocated.
4 ® Intel Image Processing Library Reference Manual Convert Converts source image data to resultant image according to the image headers. void iplConvert(IplImage* srcImage, IplImage* dstImage); srcImage The source image. dstImage The resultant image. Discussion The function iplConvert() converts image data from the source image to the resultant image according to the attributes defined in the source and resultant IplImage headers; see Example 4-6. The main conversion rule is saturation.
Image Creation and Access 4 Example 4-6 Converting Images int example46( void ) { IplImage *imga, *imgb; __try { imga = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_QWORD, 100, 150, NULL, NULL, NULL, NULL); if( NULL == imga ) return 0; imgb = iplCreateImageHeader( 1, 0, IPL_DEPTH_16S, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_QWORD, 100, 150, NULL, NULL, NULL, NULL); if( NULL == imgb ) return 0; iplAllocateImage( imga, 1, 128
4 ® Intel Image Processing Library Reference Manual PutPixel, GetPixel Sets/retrieves a value of an image’s pixel. void iplPutPixel(IplImage* image, int x, int y, void* pixel); void iplGetPixel(IplImage* image, int x, int y, void* pixel); image x, y pixel An image header with allocated image data. The pixel coordinates. The pointer to a buffer storing the consecutive channel values for the pixel.
Image Creation and Access 4 Example 4-7 Using the Function iplGetPixel() int example_1001( void ) { char pixel[4]; /// buffer to get pixel data /// roi to set different data in different channels IplROI roi = { 0, 0,0, 4,4 }; IplImage *img = iplCreateImageHeader( 4, 4, IPL_DEPTH_8U, "RGBA", "BGRA", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_DWORD, 4, 4, &roi, NULL, NULL, NULL); /// alpha-channel will be 4 iplAllocateImage( img, 1, 4 ); roi.coi = 1; iplSet( img, 1 ); roi.coi = 2; iplSet( img, 2 ); roi.
4 ® Intel Image Processing Library Reference Manual Scale Scales the image data. IPLStatus iplScale (const IplImage* src, IplImage* dst); src The source image. dst The resultant image with data of a different type. Discussion The function iplScale() converts the data of the input image src to the data type of the output image dst.
4 Image Creation and Access ScaleFP Converts the image data to and from floating-point type by scaling. IPLStatus iplScaleFP (const IplImage* src, IplImage* dst, float minVal, float maxVal); srcImage The source image. dstImage The resultant image. minVal, maxVal The floating-point data range (minVal
4 ® Intel Image Processing Library Reference Manual NoiseImage Generates noise signal and adds it to an image data. IPLStatus iplNoiseImage ( IplImage* image, const IplNoiseParam* noiseParam); image Pointer to the image header structure. noiseParam Pointer to the structure that contains parameters for the noise generator. Discussion The function iplNoiseImage() generates a random noise signal and adds it to a source image image that is passed to this function as an argument.
4 Image Creation and Access NoiseUniformInit, NoiseUniformInitFp Initializes parameters for generating noise signal with uniform distribution. void iplNoiseUniformInit ( IplINoiseParam* noiseParam, unsigned int seed, int low, int high); void iplNoiseUniformInitFp ( IplINoiseParam* noiseParam, unsigned int seed, float low, float high); noiseParam Pointer to the structure that contains parameters for the noise generator. seed The initial seed value for the pseudo-random number generator.
4 ® Intel Image Processing Library Reference Manual NoiseGaussianInit, NoiseGaussianInitFp Initializes parameters for generating noise signal with Gaussian distribution. void iplNoiseGaussianInit ( IplINoiseParam* noiseParam, unsigned int seed, int mean, int stDev); void iplNoiseGaussianInitFp ( IplINoiseParam* noiseParam, unsigned int seed, float mean, float stDev); noiseParam Pointer to the structure that contains parameters for the noise generator.
4 Image Creation and Access Working in the Windows DIB Environment The Image Processing Library provides functions to convert images to and from the Windows* device-independent bitmap (DIB). Table 4-2 shows that the IplImage format can represent more features than the DIB image format. However, the DIB palette images and 8-bit- and 16-bit-per-pixel absolute color DIB images have no equivalent in the Image Processing Library.
4 4-46 ® Intel Image Processing Library Reference Manual iplConvertFromDIB(), iplConvertFromDIBSep() Provides more control of the conversion and can convert a DIB image to an image with a prepared IplImage header. The header must be set to the desired attributes. The bit depth of the channels in the IplImage header must be equal to or greater than that in the DIB header. iplConvertToDIB(), iplConvertToDIBSep() Converts an IplImage to a DIB image.
4 Image Creation and Access TranslateDIB Translates a DIB image into the corresponding IplImage. iplImage* iplTranslateDIB(BITMAPINFOHEADER* dib, BOOL* cloneData); dib The DIB image. cloneData An output flag (Boolean): if false, indicates that the image data pointer in the IplImage will point to the DIB image data; if true, indicates that the data was copied. Discussion The function iplTranslateDIB() translates a DIB image to the IplImage format; see Example 4-8.
4 ® Intel Image Processing Library Reference Manual Example 4-8 Translating a DIB Image Into an IplImage int example47( void ) { #define WIDTH 8 #define HEIGHT 8 BITMAPINFO *dib; // pointer to bitmap RGBQUAD *rgb; // pointer to bitmap colors unsigned char *data; // pointer to bitmap data BITMAPINFOHEADER *dibh; // header beginning IplImage *img = NULL; BOOL cloneData; // variable to get result int i; __try { int size = HEIGHT * ((WIDTH+3) & ~3); // allocate memory for bitmap dib = malloc(sizeof(BITMAPINF
Image Creation and Access 4 Example 4-8 Translating a DIB Image Into an IplImage (continued) // fill in colors of the bitmap for( i=0; i<256; i++) rgb[i].rgbBlue = rgb[i].rgbGreen = rgb[i].
4 ® Intel Image Processing Library Reference Manual Return Value The constructed IplImage. If no memory is available in the system to allocate the IplImage header or image data, NULL value is returned. ConvertFromDIB Converts a DIB image to an IplImage with specified attributes. void iplConvertFromDIB(BITMAPINFOHEADER* dib, IplImage* image) dib The input DIB image. image The IplImage header with specified attributes.
4 Image Creation and Access • The dimensions of the converted IplImage should be greater than or equal to that of the DIB image. When the converted image is larger than the DIB image, the origins of IplImage and the DIB image are made coincident for the purposes of copying. • When converting a DIB RGBA image, the destination IplImage should also contain an alpha channel.
4 ® Intel Image Processing Library Reference Manual Example 4-9 Converting a DIB Image Into an IplImage (continued) dibh->biCompression = BI_RGB; dibh->biSizeImage = size; dibh->biClrUsed = 256; dibh->biClrImportant = 0; // fill in colors of the bitmap for( i=0; i<256; i++) rgb[i].rgbBlue = rgb[i].rgbGreen = rgb[i].
4 Image Creation and Access ConvertFromDIBSep Converts a DIB image to an IplImage, using two arguments for the DIB header and data. IPLStatus iplConvertFromDIBSep (BITMAPINFOHEADER* dibHeader, const char* dibData, IplImage* image); dibHeader The input DIB image header. dibData The input DIB image data. image The IplImage header with specified attributes. If the data pointer is NULL, image data memory will be allocated and the pointer set to it.
4 ® Intel Image Processing Library Reference Manual ConvertToDIB Converts an IplImage to a DIB image with specified attributes. void iplConvertToDIB(iplImage* image, BITMAPINFOHEADER* dib, int dither, int paletteConversion) image The input IplImage. dib The output DIB image. dither The dithering algorithm to use if applicable. Dithering will be done if the bit depth in the DIB is less than that of the IplImage.
4 Image Creation and Access IPL_PALCONV_POPULATE The popularity palette conversion algorithm is used. IPL_PALCONV_MEDCUT The median cut algorithm for palette conversion is used. Discussion The function iplConvertToDIB() converts an IplImage to a DIB image. The conversion takes place according to the source and destination image attributes. While IplImage format always uses absolute color, DIB images can be in absolute or palette color.
4 ® Intel Image Processing Library Reference Manual dibData The output DIB image data. dither The dithering algorithm to use if applicable. Dithering will be done if the bit depth in the DIB is less than that of the IplImage. The following algorithms are supported corresponding to these dither identifiers: IPL_DITHER_FS The Floid-Steinberg error diffusion dithering algorithm is used. IPL_DITHER_JJH The Jarvice-Judice-Ninke error diffusion dithering algorithm is used.
5 Image Arithmetic and Logical Operations This chapter describes image processing functions that modify pixel values using simple arithmetic or logical operations. It also includes the library functions that perform image compositing based on opacity (alphablending). All these operations can be broken into two categories: monadic operations, which use single input images, and dyadic operations, which use two input images. Table 5-1 lists the functions that perform arithmetic and logical operations.
5 ® Intel Image Processing Library Reference Manual Table 5-1 Image Arithmetic and Logical Operations (continued) Group Function Name Description Arithmetic operations iplMultiply Multiplies pixel values of two images. iplMultiplyScale Multiplies pixel values of two images and scales the product. iplAndS Performs a bitwise AND operation on each pixel with a constant. iplOrS Performs a bitwise OR operation on each pixel with a constant.
Image Arithmetic and Logical Operations 5 Monadic Arithmetic Operations The sections that follow describe the library functions that perform monadic arithmetic operations (note that the iplPreMultiplyAlpha function is described in the “Image Compositing Based on Opacity” section of this chapter). All these functions use a single input image to create an output image. AddS, AddSFP Adds a constant to pixel values of the source image.
5 ® Intel Image Processing Library Reference Manual SubtractS, SubtractSFP Subtracts a constant from pixel values, or pixel values from a constant. void iplSubtractS(IplImage* srcImage, IplImage* dstImage, int value, BOOL flip); void iplSubtractSFP(IplImage* srcImage,IplImage* dstImage, float value, BOOL flip); /* IPL_DEPTH_32F only */ srcImage The source image. dstImage The resultant image. value The value to be subtracted from the pixel values.
Image Arithmetic and Logical Operations dstImage The resultant image. value An integer value by which to multiply the pixel values. 5 Discussion The functions change the image intensity by multiplying each pixel by a constant value. MultiplySScale Multiplies pixel values by a constant and scales the products. void iplMultiplySScale(IplImage* srcImage, IplImage* dstImage, int value); srcImage The source image. dstImage The resultant image.
5 ® Intel Image Processing Library Reference Manual Square Squares the pixel values of the image. void iplSquare(IplImage* srcImage, IplImage* dstImage); srcImage The source image. dstImage The resultant image. Discussion The function iplSquare() increases the intensity of an image by squaring each pixel value. Abs Computes absolute pixel values of the image. void iplAbs(IplImage* srcImage, IplImage* dstImage); srcImage The source image. dstImage The resultant image.
Image Arithmetic and Logical Operations 5 Dyadic Arithmetic Operations The sections that follow describe the functions that perform dyadic arithmetic operations. These functions use two input images to create an output image. Add Combines corresponding pixels of two images by addition. void iplAdd(IplImage* srcImageA, IplImage* srcImageB, IplImage* dstImage); srcImageA The first source image. srcImageB The second source image.
5 ® Intel Image Processing Library Reference Manual Subtract Combines corresponding pixels of two images by subtraction. void iplSubtract(IplImage* srcImageA, IplImage* srcImageB, IplImage* dstImage); srcImageA The first source image. srcImageB The second source image. dstImage The resultant image obtained as: dst_pixel = srcA_pixel - srcB_pixel. Discussion The function iplSubtract() subtracts corresponding pixels of two input images to produce the output image.
Image Arithmetic and Logical Operations 5 Discussion The function iplMultiply() multiplies corresponding pixels of two input images to produce the output image. MultiplyScale Multiplies pixel values of two images and scales the products. void iplMultiplyScale(IplImage* srcImageA, IplImage* srcImageB, IplImage* dstImage); srcImageA The first source image. srcImageB The second source image. dstImage The resultant image.
5 ® Intel Image Processing Library Reference Manual Monadic Logical Operations The sections that follow describe the functions that perform monadic logical operations. All these functions use a single input image to create an output image. LShiftS Shifts pixel values’ bits to the left. void iplLShiftS(IplImage* srcImage, IplImage* dstImage, unsigned int nShift); srcImage The source image. dstImage The resultant image. nShift The number of bits by which to shift each pixel value to the left.
Image Arithmetic and Logical Operations 5 RShiftS Divides pixel values by a constant power of 2 by shifting bits to the right. void iplRShiftS(IplImage* srcImage, IplImage* dstImage, unsigned int nShift); srcImage The source image. dstImage The resultant image. nShift The number of bits by which to shift each pixel value to the right. Discussion The function iplRShiftS()decreases the intensity of the source image by shifting the bits in each pixel value by nShift bits.
5 ® Intel Image Processing Library Reference Manual Not Performs a bitwise NOT operation on each pixel. void iplNot(IplImage* srcImage, IplImage* dstImage); srcImage The source image. dstImage The resultant image. Discussion The function iplNot() performs a bitwise NOT operation on each pixel value. AndS Performs a bitwise AND operation of each pixel with a constant. void iplAndS(IplImage* srcImage, IplImage* dstImage, unsigned int value); srcImage The source image.
Image Arithmetic and Logical Operations 5 OrS Performs a bitwise OR operation of each pixel with a constant. void iplOrS(IplImage* srcImage, IplImage* dstImage, unsigned int value); srcImage The source image. dstImage The resultant image. value The bit sequence used to perform the bitwise OR operation on each pixel. Discussion The function iplOrS() performs a bitwise OR between each pixel value and value. The least significant bit(s) of the value are used.
5 ® Intel Image Processing Library Reference Manual XorS Performs a bitwise XOR operation of each pixel with a constant. void iplXorS(IplImage* srcImage, IplImage* dstImage, unsigned int value); srcImage The source image. dstImage The resultant image. value The bit sequence used to perform the bitwise XOR operation on each pixel. Discussion The function iplXorS() performs a bitwise XOR between each pixel value and value. The least significant bit(s) of the value are used.
Image Arithmetic and Logical Operations 5 And Combines corresponding pixels of two images by a bitwise AND operation. void iplAnd(IplImage* srcImageA, IplImage* srcImageB, IplImage* dstImage); srcImageA The first source image. srcImageB The second source image. dstImage The image resulting from the bitwise operation between input images srcImageA and srcImageB. Discussion The function iplAnd() performs a bitwise AND operation between the values of corresponding pixels of two input images.
5 ® Intel Image Processing Library Reference Manual Discussion The function iplOR() performs a bitwise OR operation between the values of corresponding pixels of two input images. Xor Combines corresponding pixels of two images by a bitwise XOR operation. void iplXor(IplImage* srcImageA, IplImage* srcImageB, IplImage* dstImage); srcImageA The first source image. srcImageB The second source image. dstImage The image resulting from the bitwise operation between input images srcImageA and srcImageB.
Image Arithmetic and Logical Operations 5 Using the opacity channel for image compositing provides the capability of overlaying the arbitrarily shaped and transparent images in arbitrary positions. It also reduces aliasing effects along the edges of the combined regions by allowing some of the bottom image’s color to show through. Let us consider the example of RGBA images. Here each pixel is a quadruple (r, g, b, α) where r, g, b, and α are the red, green, blue and alpha channels, respectively.
5 ® Intel Image Processing Library Reference Manual Using Pre-multiplied Alpha Values In many cases it is computationally more efficient to store the color channels pre-multiplied by the alpha values. In the RGBA example, the pixel (r, g, b, α) would actually be stored as (r*α, g*α, b*α, α). This storage format reduces the number of multiplications required in the compositing operations. In interactive environments, when an image is composited many times, this capability is especially efficient.
Image Arithmetic and Logical Operations 5 void iplAlphaCompositeC(IplImage* srcImageA, IplImage* srcImageB, IplImage* dstImage, int compositeType, int aA, int aB, BOOL premulAlpha, BOOL divideMode); srcImageA The foreground input image. srcImageB The background input image. dstImage The resultant output image. compositeType The composition type to perform. See Table 5-2 for the type value and description. aA The constant alpha value to use for the source image srcImageA.
5 ® Intel Image Processing Library Reference Manual If srcImageB does not contain an alpha channel, then the value (1-[αA) is used for the alpha, where αA is a scaled alpha value of srcImageA in the range 0 to 1. alphaImageDst The image to use as the alpha channel for dstImage. If the image already contains an alpha channel, that channel is used. Otherwise channel 1 in the image is used as the alpha channel.
Image Arithmetic and Logical Operations • • 5 If alphaImageA and alphaImageB are both NULL, then the internal alpha channels of the two input images specified by their respective IplImage headers are used. The application has to ensure that these are set to the proper channel number prior to calling this function. If srcImageB does not have an alpha channel, then its alpha value is set to (1 - αA) where αA is the scaled alpha value of image srcImageA in the range 0 to 1.
5 ® Intel Image Processing Library Reference Manual Table 5-2 Types of Image Compositing Operations Type OVER Output Pixel (see Note) Output Pixel (pre-mult. α) Resultant Alpha Description αA*A+ A+(1-αA )*B αA+ A occludes B (1-[αA)*αB*B (1-[αA)*[αB IN αA*A*[αB A*αB αA*[αB A within B. A acts as a matte for B. A shows only where B is visible. OUT αA*A*(1-[αB) A*(1-[αB) αA *(1-[αB) A outside B. NOT-B acts as a matte for A. A shows only where B is not visible.
Image Arithmetic and Logical Operations 5 The above operation is done for each color channel in A, B, and C.
5 ® Intel Image Processing Library Reference Manual PreMultiplyAlpha Pre-multiplies alpha values of an image. void iplPreMultiplyAlpha (IplImage* image, int alphaValue); image The image for which the alpha pre-multiplication is performed. alphaValue The global alpha value to use in the range 0 to 256. If this value is negative (for example, -1), the internal alpha channel of the image is used. It is an error condition if an alpha channel does not exist.
6 Image Filtering This chapter describes linear and non-linear filtering operations supported by the Image Processing Library. Most linear filtering is performed through convolution, either with user-defined convolution kernels or with the provided fixed filter kernels. Table 6-1 lists the filtering functions. Table 6-1 Image Filtering Functions Group Function Name Description Linear Filters iplBlur Applies a simple neighborhood averaging filter.
6 ® Intel Image Processing Library Reference Manual Linear Filters Linear filtering includes a simple neighborhood averaging filter, 2D convolution operations, and a number of filters with fixed effects. Blur Applies simple neighborhood averaging filter to blur the image. void iplBlur(IplImage* srcImage, IplImage* dstImage, int nCols, int nRows, int anchorX, int anchorY); srcImage The source image. dstImage The resultant image. nCols Number of columns in the neighborhood to use.
6 Image Filtering 2D Convolution The 2D convolution is a versatile image processing primitive which can be used in a variety of image processing operations; for example, edge detection, blurring, noise removal, and feature detection. It is also known as mask convolution or spatial convolution. NOTE. In some literature sources, the 2D convolution is referred to as box filtering, which is an incorrect use of the term. A box filter is a linear averaging filter (see function iplBlur above).
6 ® Intel Image Processing Library Reference Manual In addition, iplConvolveSep2D(), a convolution function that uses separable kernels, is also provided. It works with convolution kernels that are separable into the x and y components. Before performing a convolution, you should create the convolution kernel and be able to access the kernel attributes. You can do this using the functions iplCreateConvKernel(), iplGetConvKernel(), iplCreateConvKernelFP() and iplGetConvKernelFP(). In release 2.
6 Image Filtering CreateConvKernel, CreateConvKernelChar, CreateConvKernelFP Creates a convolution kernel. IplConvKernel* iplCreateConvKernel(int nCols, int nRows, int anchorX, int anchorY, int* values, int nShiftR); IplConvKernel* iplCreateConvKernelChar(int nCols, int nRows, int anchorX, int anchorY, char* values, int nShiftR); IplConvKernelFP* iplCreateConvKernelFP(int nCols, int nRows, int anchorX, int anchorY, float *values); nCols The number of columns in the convolution kernel.
6 ® Intel Image Processing Library Reference Manual nShiftR Scale the resulting output pixel by shifting it to the right nShiftR times. Discussion Functions iplCreateConvKernel() and iplCreateConvKernelFP() are used to create convolution kernels of arbitrary size with arbitrary anchor point. The function iplCreateConvKernelChar() serves primarily for compatibility with previous releases of the library. It uses char rather than integer input values to creates the same kernel as iplCreateConvKernel().
6 Image Filtering nCols, nRows Numbers of columns and rows in the convolution kernel. Set by the function. anchorX, anchorY Pointers to the [x, y] coordinates of the anchor cell in the kernel. (See iplCreateConvKernel above.) Set by the function. values A pointer to an array of values to be used for the kernel matrix. The values are read in row-major form starting with the top left corner. There will be exactly nRows*nCols entries in this array.
6 ® Intel Image Processing Library Reference Manual DeleteConvKernel DeleteConvKernelFP Deletes a convolution kernel. void iplDeleteConvKernel(IplConvKernel* kernel); void iplDeleteConvKernelFP(IplConvKernelFP* kernel); kernel The kernel to delete. Discussion Functions iplDeleteConvKernel() and iplDeleteConvKernelFP() must be used to delete convolution kernels created, respectively, by iplCreateConvKernel() and iplCreateConvKernelFP().
6 Image Filtering nKernels The number of kernels in the array kernel. The value of nKernels can be 1 or more. combineMethod The way in which the results of applying each kernel should be combined. This argument is ignored when a single kernel is used. The following combinations are supported: IPL_SUM Sums the results. IPL_SUMSQ Sums the squares of the results. IPL_SUMSQROOT Sums the squares of the results and then takes the square root. IPL_MAX Takes the maximum of the results.
6 ® Intel Image Processing Library Reference Manual Example 6-1 Computing 2-dimensional Convolution (continued) if( NULL == imga ) return 0; iplSetBorderMode( imga, IPL_BORDER_REFLECT, IPL_SIDE_TOP| IPL_SIDE_BOTTOM|IPL_SIDE_LEFT|IPL_SIDE_RIGHT, 0); imgb = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_DWORD, 4, 4, NULL, NULL, NULL, NULL); if( NULL == imgb ) return 0; iplAllocateImage( imga, 0, 0 ); if( NULL == imga->imageData ) return 0; // fill i
6 Image Filtering ConvolveSep2D, ConvolveSep2DFP Convolves an image with a separable convolution kernel. void iplConvolveSep2D (IplImage* srcImage, IplImage* dstImage, IplConvKernel* xKernel, IplConvKernel* yKernel); void iplConvolveSep2DFP (IplImage* srcImage, IplImage* dstImage, IplConvKernelFP* xKernel, IplConvKernelFP* yKernel); srcImage The source image. dstImage The resultant image. xKernel The x or row kernel. Must contain only one row. yKernel The y or column kernel.
6 ® Intel Image Processing Library Reference Manual FixedFilter Convolves an image with a predefined kernel. int iplFixedFilter(IplImage* srcImage, IplImage* dstImage, IplFilter filter); srcImage The source image. dstImage The resultant image. filter One of predefined filter kernels (see Discussion for supported filters). Discussion The function iplFixedFilter() is used to convolve the input image srcImage with a predefined filter kernel specified by filter. The resulting output image is dstImage.
6 Image Filtering IPL_SOBEL_3x3_H A gradient filter (horizontal Sobel operator). This filter uses the kernel 1 2 1 0 0 0 -1 -2 -1 IPL_LAPLACIAN_3x3 A 3x3 Laplacian highpass filter. This filter uses the kernel -1 -1 -1 -1 8 -1 -1 -1 -1 IPL_LAPLACIAN_5x5 A 5x5 Laplacian highpass filter. This filter uses the kernel -1 -3 -4 -3 -3 0 6 0 -4 6 20 6 -3 0 6 0 -1 -3 -4 -3 -1 -3 -4 -3 -1 IPL_GAUSSIAN_3x3 A 3x3 Gaussian lowpass filter.
6 ® Intel Image Processing Library Reference Manual These filter coefficients correspond to a 2-dimensional Gaussian distribution with standard deviation 1.0. IPL_HIPASS_3x3 A 3x3 highpass filter. This filter uses the kernel -1 -1 -1 -1 8 -1 -1 -1 -1 IPL_HIPASS_5x5 A 5x5 highpass filter. This filter uses the kernel -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 24 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 IPL_SHARPEN_3x3 A 3x3 sharpening filter.
6 Image Filtering MedianFilter Apply a median filter to the image. void iplMedianFilter(IplImage* srcImage, IplImage* dstImage, int nCols, int nRows, int anchorX, int anchorY); srcImage The source image. dstImage The resultant image. nCols Number of columns in the neighborhood to use. nRows Number of rows in the neighborhood to use. anchorX, anchorY The [x, y] coordinates of the anchor cell in the neighborhood.
6 ® Intel Image Processing Library Reference Manual Example 6-2 Applying the Median Filter int example62( void ) { IplImage *imga, *imgb; __try { imga = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_DWORD, 4, 4, NULL, NULL, NULL, NULL); if( NULL == imga ) return 0; iplSetBorderMode( imga, IPL_BORDER_REFLECT, IPL_SIDE_TOP| IPL_SIDE_BOTTOM|IPL_SIDE_LEFT|IPL_SIDE_RIGHT, 0); imgb = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_OR
6 Image Filtering ColorMedianFilter Apply a color median filter to the image. void iplColorMedianFilter(IplImage* srcImage, IplImage* dstImage, int nCols, int nRows, int anchorX, int anchorY); srcImage The source image. dstImage The resultant image. nCols Number of columns in the neighborhood to use. nRows Number of rows in the neighborhood to use. anchorX, anchorY The [x, y] coordinates of the anchor cell in the neighborhood.
6 Image Filtering MaxFilter Apply a max filter to the image. void iplMaxFilter(IplImage* srcImage, IplImage* dstImage, int nCols, int nRows, int anchorX, int anchorY); srcImage The source image. dstImage The resultant image. nCols Number of columns in the neighborhood to use. nRows Number of rows in the neighborhood to use. anchorX, anchorY The [x, y] coordinates of the anchor cell in the neighborhood.
6 ® Intel Image Processing Library Reference Manual MinFilter Apply a min filter to the image. void iplMinFilter(IplImage* srcImage, IplImage* dstImage, int nCols, int nRows, int anchorX, int anchorY); srcImage The source image. dstImage The resultant image. nCols Number of columns in the neighborhood to use. nRows Number of rows in the neighborhood to use. anchorX, anchorY The [x, y] coordinates of the anchor cell in the neighborhood.
This page is left blank for double-sided printing This page is left blank for double-sided printing
Linear Image Transforms 7 This chapter describes the linear image transforms implemented in the library: Fast Fourier Transform (FFT) and Discrete Cosine Transform (DCT). Table 7-1 lists the functions performing linear image transform operations. Table 7-1 Linear Image Transform Functions Group Function Name Description Fast Fourier Transform (FFT) iplRealFft2D Computes the forward or inverse 2D FFT of an image.
7 ® Intel Image Processing Library Reference Manual The function iplRealFft2D() transforms a 2D image and produces the Fourier coefficients in the RCPack2D format. To complement this, function iplCcsFft2D() is provided that uses its input in RCPack2D format, performs the Fourier transform, and produces its output as a real 2D image. The functions iplRealFft2D() and iplCcsFft2D() together can be used to perform frequency domain filtering of images.
7 Linear Image Transforms Table 7-2 FFT Output in RCPack2D Format for Even K Re A0,0 Re A0,1 Im A0,1 ... Re A0,(L-1)/2 Im A0,(L-1)/2 Re A0,L/2 Re A1,0 Re A1,1 Im A1,1 ... Re A1,(L-1)/2 Im A1,(L-1)/2 Re A1,L/2 Im A1,0 Re A2,1 Im A2,1 ... Re A2,(L-1)/2 Im A2,(L-1)/2 Im A1,L/2 ... ... ... ... ... Re AK/2-1,0 Re AK-3,1 Im AK-3,1 ... Re AK-3,(L-1)/2 Im AK-3,(L-1)/2 Re AK/2-1,L/2 Im AK/2-1,0 Re AK-2,1 Im AK-2,1 ...
7 ® Intel Image Processing Library Reference Manual RealFft2D Computes the forward or inverse 2D FFT of an image. void iplRealFft2D(IplImage* srcImage, IplImage* dstImage, int flags); srcImage The source image. dstImage The resultant image in RCPack2D format containing the Fourier coefficients. This image must be a multi-channel image containing the same number of channels as srcImage. The data type for the image must be 8, 16 or 32 bits.
7 Linear Image Transforms Discussion The function iplRealFft2D() performs an FFT on each channel in the specified rectangular ROI of the input image srcImage and writes the Fourier coefficients in RCPack2D format into the corresponding channel of the output image dstImage. The output data will be clamped (saturated) to the limits Min and Max, which are determined by the data type of the output image. For best results, use 32-bit data or, at least, 16-bit data.
7 ® Intel Image Processing Library Reference Manual Example 7-1 Computing the FFT of an Image (continued) if( NULL == imga ) return 0; imgb = iplCreateImageHeader( 1, 0, IPL_DEPTH_16S, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_DWORD, 4, 4, NULL, NULL, NULL, NULL); if( NULL == imgb ) return 0; // Create without filling iplAllocateImage( imga, 0,0 ); if( NULL == imga->imageData ) return 0; // Fill by sample data for( i=0; i<16; i++) ((char*)imga->imageData)[i] = (char)src[i]; iplAlloca
Linear Image Transforms 7 CcsFft2D Computes the forward or inverse 2D FFT of an image in complexconjugate format. void iplCcsFft2D(IplImage* srcImage, IplImage* dstImage, int flags); srcImage The source image in RCPack2D format. dstImage The resultant image. This image must be a multi-channel image containing the same number of channels as srcImage. This image cannot be the same as the input image srcImage (that is, an in-place operation is not allowed). flags Specifies how to perform the FFT.
7 ® Intel Image Processing Library Reference Manual MpyRCPack2D Multiplies data of two images in the RCPack format. void iplMpyRCPack2D (IplImage* srcA, IplImage* srcB, IplImage* dst); srcA, srcB The source images in RCPack2D format. dst The resultant image. This image must be a multi-channel image containing the same number of channels as srcA and srcB. This image cannot be the same as the input images (that is, an in-place operation is not allowed) .
7 Linear Image Transforms DCT2D Computes the forward or inverse 2D DCT of an image. void iplDCT2D(IplImage* srcImage, IplImage* dstImage, int flags); srcImage The source image. dstImage The resultant image containing the DCT coefficients. This image must be a multi-channel image containing the same number of channels as srcImage. The data type for the image must be 8, 16 or 32 bits. This image cannot be the same as the input image srcImage (that is, an in-place operation is not allowed).
7 ® Intel Image Processing Library Reference Manual Discussion The function iplDCT2D() performs a DCT on each channel in the specified rectangular ROI of the input image srcImage and writes the DCT coefficients into the corresponding channel of the output image dstImage. The output data will be clamped (saturated) to the limits Min and Max, where Min and Max are determined by the data type of the output image. For best results, use 32-bit data or, at least, 16-bit data.
Linear Image Transforms 7 Example 7-2 Computing the DCT of an Image (continued) // Create without filling iplAllocateImage( imga, 0,0 ); if( NULL == imga->imageData ) return 0; // Fill by sample data for( i=0; iimageData)[i] = (char)(i+1); iplAllocateImage( imgb, 0, 0 ); if( NULL == imgb->imageData ) return 0; iplDCT2D( imga, imgb, IPL_DCT_Forward ); // Now there are (width+height-1) DCT coefficients for( y=1; yimageDa
This page is left blank for double-sided printing This page is left blank for double-sided printing
Morphological Operations 8 The morphological operations of the Image Processing Library are simple erosion and dilation of an image. A specified number of erosions and dilations are performed as part of image opening or closing operations in order to (respectively) eliminate or fill small and thin holes in objects, break objects at thin points or connect nearby objects, and generally smooth the boundaries of objects without significantly changing their area.
8 ® Intel Image Processing Library Reference Manual Erode Erodes the image. void iplErode(IplImage* srcImage, IplImage* dstImage, int nIterations); srcImage The source image. dstImage The resultant image. nIterations The number of times to erode the image. Discussion The function iplErode() performs an erosion of the image nIterations times. The way the image is eroded depends on whether it is a binary image, a gray-scale image, or a color image.
Morphological Operations 8 Figure 8-1 shows an example of 8-bit gray scale image before erosion (left) and the same image after erosion of a rectangular ROI (right). Figure 8-1 Erosion in a Rectangular ROI: the Source (left) and Result (right) ____________________________________________________________ The following code (Example 8-1) performs erosion of the image inside the selected rectangular ROI.
8 ® Intel Image Processing Library Reference Manual Example 8-1 Code Used to Produce Erosion in a Rectangular ROI int example81( void ) { IplImage *imga, *imgb; __try { imga = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_DWORD, 4, 4, NULL, NULL, NULL, NULL); if( NULL == imga ) return 0; imgb = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_DWORD, 4, 4, NULL, NULL, NULL, NULL); if( NULL ==
8 Morphological Operations NOTE. All source image attributes are defined in the image header pointed to by srcImage. Dilate Dilates the image. void iplDilate(IplImage* srcImage, IplImage* dstImage, int nIterations); srcImage The source image. dstImage The resultant image. nIterations The number of times to dilate the image. Discussion The function iplDilate() performs a dilation of the image nIterations times.
8 ® Intel Image Processing Library Reference Manual Open Opens the image by performing erosions followed by dilations. void iplOpen(IplImage* srcImage, IplImage* dstImage, int nIterations); srcImage The source image. dstImage The resultant image. nIterations The number of times to erode and dilate the image. Discussion The function iplOpen() performs nIterations of erosion followed by nIterations of dilation performed by iplErode() and iplDilate(), respectively.
8 Morphological Operations Close Closes the image by performing dilations followed by erosions. void iplClose(IplImage* srcImage, IplImage* dstImage, int nIterations); srcImage The source image. dstImage The resultant image. nIterations The number of times to dilate and erode the image. Discussion The function iplClose() performs nIterations of dilation followed by nIterations of erosion performed by iplDilate() and iplErode(), respectively.
This page is left blank for double-sided printing This page is left blank for double-sided printing
9 Color Space Conversion This chapter describes the Image Processing Library functions that perform color space conversion. The library supports the following color space conversions: • Reduction from high bit resolution color to low bit resolution color • Conversion of absolute color images to and from palette color images • Color model conversion • Conversion from color to gray scale and vice versa Table 9-1 lists color space conversion functions.
9 ® Intel Image Processing Library Reference Manual Table 9-1 Conversion Type Function Name Description Color Models Conversion iplRGB2LUV, iplLUV2RGB Convert RGB images to and from LUV color model. (continued) iplRGB2XYZ, iplXYZ2RGB Convert RGB images to and from XYZ color model. iplRGB2YCrCb, iplYCrCb2RGB Convert RGB images to and from YCrCb color model. iplRGB2YUV, iplYUV2RGB Convert RGB images to and from YUV color model. iplYCC2RGB Convert PhotoYCC* images to RGB color model.
9 Color Space Conversion Reducing the Image Bit Resolution This section describes functions that reduce the bit resolution of absolute color and gray scale images. ReduceBits Reduces the number of intensity levels in an image. void iplReduceBits(IplImage* srcImage, IplImage* dstImage, int noise, int ditherType, int levels); srcImage The source image . dstImage The resultant image. noise The number specifying the noise added. This parameter is set as a percentage of range [0..100].
9 ® Intel Image Processing Library Reference Manual IPL_DITHER_BAYER The Bayer threshold dithering algorithm. The number of output levels for halftoning (dithering); can be varied in the range [2..(1<
Color Space Conversion 9 The figure below illustrates the results of applying the iplReduceBits() function with Stucki dithering to a source image that has 256 intensity levels. The output images both have 2 intensity levels, the difference is in the value of noise added for the error diffusion dithering algorithm.
9 ® Intel Image Processing Library Reference Manual Output image Output image (levels=2, noise=0) (levels=2, noise=20) Table 9-2 lists the valid combinations of the source and resultant image bit data types for reducing the bit resolution.
9 Color Space Conversion Conversion from Bitonal to Gray Scale Images This section describes the function that performs the conversion of bitonal images to gray scale. BitonalToGray Converts a bitonal image to gray scale. void iplBitonalToGray(IplImage* srcImage, IplImage* dstImage, int ZeroScale, int OneScale); srcImage The bitonal source image. dstImage The resultant gray scale image. (See the discussion below.
9 ® Intel Image Processing Library Reference Manual Conversion from Color to Gray Scale This section describes the function that performs the conversion of absolute color images to gray scale. ColorToGray Converts a color image to gray scale. void iplColorToGray(IplImage* srcImage, IplImage* dstImage); srcImage The source image. See Table 9-3 for a list of valid source and resultant image combinations. dstImage The resultant image.
9 Color Space Conversion The weights to compute true luminance from linear red, green and blue are these: Y = 0.212671 * R + 0.715160 * G + 0.072169 * B Conversion from Gray Scale to Color (Pseudo-color) This section describes the conversion of gray scale image to pseudo color. GrayToColor Converts a gray scale to color image. void iplGrayToColor (IplImage* srcImage, IplImage* dstImage, float FractR, float FractG, float FractB); srcImage The source image.
9 ® Intel Image Processing Library Reference Manual Table 9-4 Source and Resultant Image Data Types for Conversion from Gray Scale to Color Source Image (data type) Resultant image (data type) Gray scale 1 bit 8 bit per channel Gray scale 8 bit 8 bit per channel Gray scale 16 bit 16 bit per channel Gray scale 32 bit 32 bit per channel The equations for chrominance in RGB from luminance Y are: R = FractR * Y; G = FractG * Y; B = FractB * Y; 0 <= FractR <= 1 0 <= FractG <= 1 0 <= FractB <= 1.
9 Color Space Conversion This call converts the RGB image rgbImage to the CMY image cmyImage by setting each channel in the CMY image as follows: C = 255 - R M = 255 - G Y = 255 - B The conversion from CMY to RGB is similar: just switch the RGB and CMY images.
9 ® Intel Image Processing Library Reference Manual RGB2HSV Converts RGB images to the HSV color model. void iplRGB2HSV(IplImage* rgbImage, IplImage* hsvImage); rgbImage The source RGB image. hsvImage The resultant HSV image. Discussion The function converts the RGB image rgbImage to the HSV image hsvImage. The function checks that the input image is an RGB image. The channel sequence and color model of the output image are set to HSV. HSV2RGB Converts HSV images to the RGB color model.
9 Color Space Conversion RGB2HLS Converts RGB images to the HLS color model. void iplRGB2HLS(IplImage* rgbImage, IplImage* hlsImage); rgbImage The source RGB image. hlsImage The resultant HLS image. Discussion The function converts the RGB image rgbImage to the HLS image hlsImage. The function checks that the input image is an RGB image. The function sets the channel sequence and color model of the output image to HLS. HLS2RGB Converts HLS images to the RGB color model.
9 ® Intel Image Processing Library Reference Manual RGB2LUV Converts RGB images to the LUV color model. void iplRGB2LUV(IplImage* rgbImage, IplImage* luvImage); rgbImage The source RGB image. luvImage The resultant LUV image. Discussion The function converts the RGB image rgbImage to the LUV image luvImage. The function checks that the input image is an RGB image; it sets the channel sequence and color model of the output image to LUV. The function processes 32f images only.
9 Color Space Conversion RGB2XYZ Converts RGB images to the XYZ color model. void iplRGB2XYZ(IplImage* rgbImage, IplImage* xyzImage); rgbImage xyzImage The source RGB image. The resultant XYZ image. Discussion The function converts the RGB image rgbImage to the XYZ image xyzImage according to the following formulas: X = 0.4124·R + 0.3576·G + 0.1805·B Y = 0.2126·R + 0.7151·G + 0.0721·B Z = 0.0193·R + 0.1192·G + 0.9505·B.
9 ® Intel Image Processing Library Reference Manual RGB2YCrCb Converts RGB images to the YCrCb color model. void iplRGB2YCrCb(IplImage* rgbImage, IplImage* YCrCbImage); rgbImage YCrCbImage The source RGB image. The resultant YCrCb image. Discussion The function converts the RGB image rgbImage to the YCrCb image YCrCbImage (via the YUV model) according to the following formulas: Y = 0.3·R + 0.6·G + 0.1·B U=B-Y Cb = 0.5·(U + 1) Cr = V/1.6 + 0.5.
9 Color Space Conversion RGB2YUV Converts RGB images to the YUV color model. void iplRGB2YUV(IplImage* rgbImage, IplImage* yuvImage); rgbImage yuvImage The source RGB image. The resultant YUV image. Discussion The function converts the RGB image rgbImage to the YUV image yuvImage according to the following formulas: Y = 0.3·R + 0.6·G + 0.1·B U=B-Y V = R - Y. The function checks that the input image is an RGB image; it sets the channel sequence and color model of the output image to YUV.
9 ® Intel Image Processing Library Reference Manual YCC2RGB Converts HLS images to the RGB color model. void iplYCC2RGB(IplImage* YCCImage, IplImage* rgbImage); The source YCC image. The resultant RGB image. YCCImage rgbImage Discussion The function converts the YCC image YCCImage to the RGB image rgbImage; see [Rogers85]. The function checks that the input image is an YCC image and that the output image is RGB. Both images must be 8-bit unsigned.
9 Color Space Conversion CreateColorTwist Creates a color-twist matrix data structure. IplColorTwist* iplCreateColorTwist(int data[16], int scalingValue); data An array containing the sixteen values that constitute the color-twist matrix. The values are in row-wise order. Color-twist values that are in the range -1 to 1 should be 31 31 scaled up to be in the range -2 to 2 -1. (Simply multiply the floating point number 31 in the -1 to 1 range by 2 .
9 ® Intel Image Processing Library Reference Manual SetColorTwist Sets a color-twist matrix data structure. void iplSetColorTwist(IplColorTwist* cTwist, int data[16], int scalingValue); data An array containing the sixteen values that constitute the color-twist matrix. The values are in row-wise order. Color-twist values that are in the range -1 to 1 should be 31 31 scaled up to be in the range -2 to 2 . (Simply multiply the floating point number 31 in the -1 to 1 range by 2 .
9 Color Space Conversion ApplyColorTwist Applies a color-twist matrix to an image. void iplApplyColorTwist(IplImage* srcImage, IplImage* dstImage, IplColorTwist* cTwist, int offset); srcImage The source image. dstImage The resultant image. cTwist The color-twist matrix data structure that was prepared by a call to the function iplSetColorTwist(). offset An offset value that will be added to each pixel channel after multiplication by the color-twist matrix.
9 ® Intel Image Processing Library Reference Manual • • • • • Lightening an image Color saturation Color balance R, G, and B color adjustments Contrast adjustment. DeleteColorTwist Frees memory used for a color-twist matrix. void iplDeleteColorTwist(IplColorTwist* cTwist); cTwist The color-twist matrix data structure that was prepared by a call to the function iplCreateColorTwist().
9 Color Space Conversion ColorTwistFP Applies a color-twist matrix to an image with floating-point pixel values. IPLStatus iplColorTwistFP (const IplImage* src, IplImage* dst, float* cTwist) src The source image. dst The resultant image. cTwist The array containing color-twist matrix elements. Discussion The function iplColorTwistFP() applies the color-twist matrix stored in the array cTwist to each of the first three color channels.
This page is left blank for double-sided printing This page is left blank for double-sided printing
Histogram, Threshold, and Compare Functions 10 This chapter describes functions that operate on an image on a pixel-bypixel basis: compare, threshold, and histogram functions. Table 10-1 lists all functions in these groups. Table 10-1 Histogram, Threshold, and Compare Functions Group Function Name Description Thresholding iplThreshold Performs a simple thresholding of an image.
10 ® Intel Image Processing Library Reference Manual Table 10-1 Compare, Threshold, and Histogram Functions (continued) Group Function Name Description Comparing Images (continued) iplEqualFPEps Performs an equality test with tolerance ε for two input images containing 32-bit floating-point pixel data and writes the results (0 or 1) to each pixel of the output image.
Histogram, Threshold, and Compare Functions threshold 10 The threshold value to use for each pixel. The pixel value in the output is set to the maximum presentable value if it is greater than or equal to the threshold value (for each channel). Otherwise the pixel value in the output is set to the minimum presentable value. Discussion The function iplThreshold() thresholds the source image srcImage using the value threshold to create the resultant image dstImage.
10 ® Intel Image Processing Library Reference Manual Example 10-1 Conversion to a Bitonal Image int example101( void ) { IplImage *imga, *imgb; const int width = 4, height = 4; __try { imga = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_DWORD, width, height, NULL, NULL, NULL, NULL); if( NULL == imga ) return 0; imgb = iplCreateImageHeader( 1, 0, IPL_DEPTH_1U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_DWORD, width, height, NU
Histogram, Threshold, and Compare Functions 10 Lookup Table (LUT) and Histogram Operations A LUT can be used to specify an intensity transformation. Given an input intensity, LUT can be used to look up an output intensity. Usually a LUT is provided for each channel in the image, although sometimes the same LUT can be shared by many channels. The IplLUT Structure You can set a lookup table using the IplLUT structure.
10 ® Intel Image Processing Library Reference Manual If interpolateType is LOOKUP, then any input intensity D in the range k0 ≤ D < k1 will result in the value v0, in the range k1 ≤ D < k2 will result in the value v1 and so on.
10 Histogram, Threshold, and Compare Functions ConstrastStretch Stretches the contrast of an image using an intensity transformation. void iplContrastStretch(IplImage* srcImage, IplImage* dstImage, IplLUT** lut); srcImage The source image. dstImage The resultant image. lut An array of pointers to LUTs, one pointer for each channel. Each lookup table should have the key, value and factor arrays fully initialized (see “The IplLUT Structure”). One or more channels may share the same LUT.
10 ® Intel Image Processing Library Reference Manual Example 10-2 Using the Function iplContrastStretch() to Enhance an Image (continued) /// allocate LUT's arrays lut.key = malloc( sizeof(int)*(range+1) ); lut.value = malloc( sizeof(int)*range ); lut.factor = malloc( sizeof(int)*range ); /// make the image with a narrow and shifted range iplRShiftS( img, img, 4 ); iplAddS( img, img, 4 ); /// compute histogram and find min and max values for( i=0; i<=range; i++) lut.
Histogram, Threshold, and Compare Functions 10 ComputeHisto Computes the intensity histogram of an image. void iplComputeHisto(IplImage* srcImage, IplLUT** lut); srcImage The source image for which the histogram will be computed. lut An array of pointers to LUTs, one pointer for each channel. Each lookup table should have the key array fully initialized. The value array will be filled by this function. (For the key and value arrays, see “The IplLUT Structure” above.
10 ® Intel Image Processing Library Reference Manual HistoEqualize Enhances an image by flattening its intensity histogram. void iplHistoEqualize(IplImage* srcImage, IPLImage* dstImage, IplLUT** lut); srcImage The source image for which the histogram will be computed. dstImage The resultant image after equalizing. lut The histogram of the image is represented as an array of pointers to LUTs, one pointer for each channel. Each lookup table should have the key and value arrays fully initialized.
Histogram, Threshold, and Compare Functions 10 Example 10-3 Computing and Equalizing the Image Histogram int example102( void ) { IplImage *imga; const int width = 4, height = 4, range = 256; IplLUT lut = { range+1, NULL,NULL,NULL, IPL_LUT_LOOKUP }; IplLUT* plut = &lut; __try { int i; lut.key = malloc( sizeof(int)*(range+1) ); lut.
10 ® Intel Image Processing Library Reference Manual Comparing Images This section describes the functions that allow you to compare images. Each compare function writes its results to a 1-bit output image. The output pixel is set to 1 if the corresponding input pixel(s) satisfied the compare condition; otherwise, the output pixel is set to 0. Often, you might wish to use the compare functions to generate a 1-bit mask image for future use in other image-processing operations.
Histogram, Threshold, and Compare Functions 10 Greater Tests if the pixel values of the first image are greater than those of the second image. IPLStatus iplGreater (IplImage* img1, IplImage* img2, IplImage* dst); img1, img2 The source images. dst The resultant 1-bit image. Discussion The function iplGreater() compares the corresponding pixels of two input images for “greater than” and writes the results to a 1-bit image dst.
10 ® Intel Image Processing Library Reference Manual Less Tests if the pixel values of the first image are less than those of the second image. IPLStatus iplLess (IplImage* img1, IplImage* img2, IplImage* dst); img1, img2 The source images. dst The resultant 1-bit image. Discussion The function iplLess() compares the corresponding pixels of two input images for “less than” and writes the results to a 1-bit image dst.
Histogram, Threshold, and Compare Functions 10 Equal Tests if the pixel values of the first image are equal to those of the second image. IPLStatus iplEqual (IplImage* img1, IplImage* img2, IplImage* dst); img1, img2 The source images. dst The resultant 1-bit image. Discussion The function iplEqual() compares the corresponding pixels of two input images for equality and writes the results to a 1-bit image dst.
10 ® Intel Image Processing Library Reference Manual EqualFPEps Tests if the floating-point pixel values in two images are equal within a tolerance ε. IPLStatus iplEqualFPEps (IplImage* img1, IplImage* img2, IplImage* dst, float eps); img1, img2 The source images. dst The resultant 1-bit image. eps The tolerance value. Discussion The function iplEqualFPEps() tests if the corresponding pixels of two input images are equal within the tolerance eps, and writes the results to a 1-bit image dst.
Histogram, Threshold, and Compare Functions 10 GreaterS Tests if the image’s pixel values are greater than an integer scalar value. IPLStatus iplGreaterS (IplImage* src, int s, IplImage* dst); src The source image. s The integer scalar value to be compared with pixel values. dst The resultant 1-bit image. Discussion The function iplGreaterS() compares the pixels of the input image src and a scalar value s for “greater than” and writes the results to a 1-bit image dst.
10 ® Intel Image Processing Library Reference Manual GreaterSFP Tests if the image’s pixel values are greater than a floating-point scalar value. IPLStatus iplGreaterSFP (IplImage* src, float s, IplImage* dst); src The source image. s The 32-bit floating-point scalar value to be compared with pixel values. dst The resultant 1-bit image.
Histogram, Threshold, and Compare Functions 10 LessS Tests if the image’s pixel values are less than an integer scalar value. IPLStatus iplLessS (IplImage* src, int s, IplImage* dst); src The source image. s The integer scalar value to be compared with pixel values. dst The resultant 1-bit image. Discussion The function iplLessS() compares the pixels of the input image src and a scalar value s for “less than” and writes the results to a 1-bit image dst.
10 ® Intel Image Processing Library Reference Manual LessSFP Tests if the image’s pixel values are less than a floating-point scalar value. IPLStatus iplLessSFP (IplImage* src, float s, IplImage* dst); src The source image. s The 32-bit floating-point scalar value to be compared with pixel values. dst The resultant 1-bit image. Discussion The function iplLessSFP() compares the pixels of the input image src and a scalar value s for “less than” and writes the results to a 1-bit image dst.
Histogram, Threshold, and Compare Functions 10 EqualS Tests if the image’s pixel values are equal to an integer scalar value. IPLStatus iplEqualS (IplImage* src, int s, IplImage* dst); src The source image. s The integer scalar value to be compared with pixel values. dst The resultant 1-bit image. Discussion The function iplEqualS() compares the pixels of the input image src and an integer scalar value s for equality and writes the results to a 1-bit image dst.
10 ® Intel Image Processing Library Reference Manual EqualSFP Tests if the image’s pixel values are equal to a floating-point scalar value. IPLStatus iplEqualSFP (IplImage* src, float s, IplImage* dst); src The source image. s The 32-bit floating-point scalar value to be compared with pixel values. dst The resultant 1-bit image. Discussion The function iplEqualSFP() compares the pixels of the input image src and a scalar value s for equality and writes the results to a 1-bit image dst.
Histogram, Threshold, and Compare Functions 10 EqualSFPEps Tests if the pixel values are equal to a floating-point scalar value within a tolerance ε. IPLStatus iplEqualSFPEps (IplImage* src, float s, IplImage* dst, float eps); src The source image. s The 32-bit floating-point scalar value to be compared with pixel values. dst The resultant 1-bit image. eps The tolerance ε.
This page is left blank for double-sided printing This page is left blank for double-sided printing
11 Geometric Transforms This chapter describes the functions that perform geometric transforms to resize the image, change the image orientation, or warp the image. There is also a special function, iplRemap(), for performing geometric transforms with a user-defined coordinate mapping. Table 11-1 lists image geometric transform functions and macro definitions. Table 11-1 Image Geometric Transform Functions and Macros Group Function Name Description Resizing iplZoom Zooms or expands an image.
11 Table 11-1 ® Intel Image Processing Library Reference Manual Image Geometric Transform Functions (continued) Group Function Name Description Warping (cont.) iplWarpBilinear Performs a bilinear transform with the specified coefficients. iplWarpBilinearQ Performs a bilinear transform with the specified reference quadrangle. iplWarpPerspective Performs a perspective transform with the specified coefficients.
Geometric Transforms 11 Internally, all geometric transformation functions handle regions of interest (ROIs) with the following sequence of operations: • transform the rectangular ROI of the source image to a quadrangle in the destination image • find the intersection of this quadrangle and the rectangular ROI of the destination image • update the destination image in the intersection area, taking into account mask images (if any).
11 ® Intel Image Processing Library Reference Manual Zoom Zooms or expands an image. void iplZoom(IplImage* srcImage, IplImage* dstImage, int xDst, int xSrc, int yDst, int ySrc, int interpolate); srcImage The source image. dstImage The resultant image. xDst,xSrc,yDst,ySrc Positive integers specifying the fractions xDst/xSrc ≥ 1 and yDst/ySrc ≥ 1 - the factors by which the x and y dimensions of the image’s ROI are changed.
11 Geometric Transforms Decimate Decimates or shrinks an image. void iplDecimate(IplImage* srcImage, IplImage* dstImage, int xDst, int xSrc, int yDst, int ySrc, int interpolate); srcImage The source image. dstImage The resultant image. xDst,xSrc,yDst,ySrc Positive integers specifying the fractions xDst/xSrc ≤ 1 and yDst/ySrc ≤ 1 - the factors by which the x and y dimensions of the image’s ROI are changed.
11 ® Intel Image Processing Library Reference Manual DecimateBlur Blurs and decimates an image. void iplDecimateBlur (IplImage* srcImage, IplImage* dstImage, int xDst, int xSrc, int yDst, int ySrc, int interpolate, int xMaskSize, int yMaskSize); srcImage The source image. dstImage The resultant image. xDst,xSrc,yDst,ySrc Positive integers specifying the fractions xDst/xSrc ≤ 1 and yDst/ySrc ≤ 1 - the factors by which the x and y dimensions of the image’s ROI are changed (similar to iplDecimate).
11 Geometric Transforms Resize Resizes an image. void iplResize(IplImage* srcImage, IplImage* dstImage, int xDst, int xSrc, int yDst, int ySrc, int interpolate); srcImage The source image. dstImage The resultant image. xDst,xSrc,yDst,ySrc Positive integers specifying the fractions xDst/xSrc and yDst/ySrc - the factors by which the x and y dimensions of the image’s ROI are changed. For example, setting xDst = 1, xSrc = 2, yDst = 2, ySrc = 1 halves the x and doubles the y dimension.
11 ® Intel Image Processing Library Reference Manual iplZoomFit iplDecimateFit iplResizeFit Macro definitions that change the image size using the images’ dimensions as scaling factors. iplZoomFit( SRC, DST, INTER ); iplDecimateFit( SRC, DST, INTER ); iplResizeFit( SRC, DST, INTER ); SRC The source image. DST The destination image. INTER The type of interpolation to perform for resampling the source image.
11 Geometric Transforms Example 11-1 Using Macro Definition to Resize an Image int ResizeFit( void ) { IplImage *imga = iplCreateImageJaehne( IPL_DEPTH_8U, 5, 5 ); IplImage *imgb = iplCreateImageJaehne( IPL_DEPTH_8U, 7, 7 ); IPLStatus st; iplResizeFit( imga, imgb, IPL_INTER_NN ); st = iplGetErrStatus(); iplDeallocate( imga, IPL_IMAGE_ALL ); iplDeallocate( imgb, IPL_IMAGE_ALL ); return IPL_StsOk == st; } Changing the Image Orientation The functions described in this section change the image orientation by
11 ® Intel Image Processing Library Reference Manual dstImage The resultant image. angle The angle (in degrees) to rotate the image. The image is rotated around the corner with coordinates (0,0). xShift, yShift The shifts along the x- and y-axes to be performed after the rotation. interpolate The type of interpolation to perform for resampling the source image. The following modes are supported: IPL_INTER_NN Nearest neighbor. IPL_INTER_LINEAR Linear interpolation.
11 Geometric Transforms GetRotateShift Computes shifts for iplRotate, given the rotation center and angle. void iplGetRotateShift(double xCenter, double yCenter, double angle, double* xShift, double* yShift); xCenter, yCenter Coordinates of the rotation center for which you wish to compute the shifts. angle The angle (in degrees) to rotate the image around the point with coordinates (xCenter, yCenter).
11 ® Intel Image Processing Library Reference Manual Example 11-2 Rotating an Image (continued) double xshift=0, yshift=0; imga = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_DWORD, width, height, NULL, NULL, NULL, NULL); if( NULL == imga ) return 0; imgb = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_DWORD, width, height, NULL, NULL, NULL, NULL); if( NULL == imgb ) return 0; // Create
11 Geometric Transforms iplRotateCenter This function-like macro allows to rotate an image around the given center. iplRotateCenter(srcImage, dstImage, angle, xCenter, yCenter, interpolate); srcImage The source image. dstImage The destination image. angle The angle (in degrees) to rotate the image around the point with coordinates (xCenter, yCenter). xCenter, yCenter Coordinates of the center of rotation. interpolate The type of interpolation to perform for resampling the input image.
11 ® Intel Image Processing Library Reference Manual Example 11-3 Using Macro Definition to Rotate an Image int RotateCenter( void ) { IplImage *imga = iplCreateImageJaehne(IPL_DEPTH_8U, 5, 5); IplImage *imgb = iplCloneImage( imga ); IPLStatus st; // Rotate by 45 about point(2,2) iplRotateCenter( imga, imgb, 45, 2, 2, IPL_INTER_NN ); st = iplGetErrStatus(); iplDeallocate( imga, IPL_IMAGE_ALL ); iplDeallocate( imgb, IPL_IMAGE_ALL ); return IPL_StsOk == st; } Mirror Mirrors an image about a horizontal or
Geometric Transforms 11 Warping This section describes shearing and warping functions of the Image Processing Library. These functions have been added in release 2.0. They perform the following operations: • affine warping (the functions iplWarpAffine and iplShear) • bilinear warping (iplWarpBilinear, iplWarpBilinearQ) • perspective warping (iplWarpPerspective, iplWarpPerspectiveQ). Affine warping operations are more complex and more general than resizing or rotation.
11 ® Intel Image Processing Library Reference Manual Shear Performs a shear of the source image. void iplShear(IplImage* srcImage, IplImage* dstImage, double xShear, double yShear, double xShift, double yShift, int interpolate); srcImage The source image. dstImage The resultant image. xShear, yShear The shear coefficients. xShift, yShift Additional shift values for the x and y directions. interpolate The type of interpolation to perform for resampling.
11 Geometric Transforms WarpAffine Warps an image by an affine transform. void iplWarpAffine(IplImage* srcImage, IplImage* dstImage, const double coeffs[2][3], int interpolate); srcImage The source image. dstImage The resultant image. coeffs The affine transform coefficients. interpolate The type of interpolation to perform for resampling. Can be one of the following: IPL_INTER_NN Nearest neighbor. IPL_INTER_LINEAR Linear interpolation. IPL_INTER_CUBIC Cubic interpolation.
11 ® Intel Image Processing Library Reference Manual GetAffineBound Computes the bounding rectangle for ROI transformed by iplWarpAffine. void iplGetAffineBound(IplImage* image, const double coeffs[2][3], double rect[2][2]); image The image to be passed to iplWarpAffine(). coeffs The iplWarpAffine() transform coefficients. rect Output array: the coordinates of vertices of the rectangle bounding the figure to which iplWarpAffine() maps image’s ROI.
11 Geometric Transforms quad Output array: coordinates of the quadrangle to which the image’s ROI would be mapped by iplWarpAffine(). Discussion The function iplGetAffineQuad() computes coordinates of the quadrangle to which the image’s ROI would be mapped by iplWarpAffine() with the transform coefficients coeffs. GetAffineTransform Computes the iplWarpAffine coefficients, given the ROIquadrangle pair.
11 ® Intel Image Processing Library Reference Manual WarpBilinear WarpBilinearQ Warps an image by a bilinear transform. void iplWarpBilinear(IplImage* srcImage, IplImage* dstImage, const double coeffs[2][4], int warpFlag, int interpolate); void iplWarpBilinearQ(IplImage* srcImage, IplImage* dstImage, const double quad[4][2], int warpFlag, int interpolate); srcImage The source image. dstImage The resultant image. coeffs Array with bilinear transform coefficients.
Geometric Transforms 11 Discussion The functions iplWarpBilinear() and iplWarpBilinearQ() warp the source image by a bilinear transformation according to the following formulas: x’ = c00·xy + c01·x + c02·y + c03 y’ = c10·xy + c11·x + c12·y + c13 where x and y denote the original pixel coordinates; x’ and y’ denote the pixel coordinates in the transformed image.
11 ® Intel Image Processing Library Reference Manual GetBilinearBound Computes the bounding rectangle for ROI transformed by iplWarpBilinear. void iplGetBilinearBound(IplImage* image, const double coeffs[2][4], double rect[2][2]); image The image to be passed to iplWarpBilinear(). coeffs The bilinear transform coefficients. rect Output array: the coordinates of vertices of the rectangle bounding the figure to which iplWarpBilinear() maps image’s ROI.
11 Geometric Transforms quad Output array: coordinates of the quadrangle to which the image’s ROI would be mapped by iplWarpBilinear(). Discussion The function iplGetBilinearQuad() computes coordinates of the quadrangle to which the image’s ROI would be mapped by iplWarpBilinear() with the transform coefficients coeffs. GetBilinearTransform Computes the iplWarpBilinear coefficients, given the ROIquadrangle pair.
11 ® Intel Image Processing Library Reference Manual WarpPerspective WarpPerspectiveQ Warps an image by a perspective transform. void iplWarpPerspective(IplImage* srcImage, IplImage* dstImage, const double coeffs[3][3], int warpFlag, int interpolate); void iplWarpPerspectiveQ(IplImage* srcImage, IplImage* dstImage, const double quad[4][2], int warpFlag, int interpolate); srcImage The source image. dstImage The resultant image. coeffs Array with perspective transform coefficients.
Geometric Transforms 11 Discussion The functions iplWarpPerspective() and iplWarpPerspectiveQ() warp the source image by a perspective transformation according to the following formulas: x’ = (c00·x + c01·y + c02)/(c20·x + c21·y + c22) y’ = (c10·x + c11·y + c12)/(c20·x + c21·y + c22) where x and y denote the original pixel coordinates; x’ and y’ denote the pixel coordinates in the transformed image.
11 ® Intel Image Processing Library Reference Manual GetPerspectiveBound Computes the bounding rectangle for ROI transformed by iplWarpPerspective. void iplGetPerspectiveBound(IplImage* image, const double coeffs[3][3], double rect[2][2]); image The image to be passed to iplWarpPerspective(). coeffs The perspective transform coefficients. rect Output array: the coordinates of vertices of the rectangle bounding the figure to which iplWarpPerspective() maps image’s ROI.
11 Geometric Transforms quad Output array: coordinates of the quadrangle to which the image’s ROI would be mapped by iplWarpPerspective(). Discussion The function iplGetPerspectiveQuad() computes coordinates of the quadrangle to which the image’s ROI would be mapped by iplWarpPerspective() with the transform coefficients coeffs. GetPerspectiveTransform Computes the coefficients of iplWarpPerspective, given the ROI-quadrangle pair.
11 ® Intel Image Processing Library Reference Manual Arbitrary Transforms To perform special geometric transforms not covered in the above sections, the Image Processing Library includes the iplRemap() function. Unlike other geometric transform functions, iplRemap() uses coordinate tables supplied by the application. For each pixel in the destination image, you have to provide coordinates of the source image’s point which you would like to be mapped to that destination pixel.
11 Geometric Transforms Discussion The function iplRemap() maps the image srcImage to dstImage using a coordinate table supplied by the application in the images xMap and yMap. To each pixel in the destination image dstImage, the function assigns the value taken from the point (x,y) in the source image; the coordinates x and y are retrieved from the locations in xMap and yMap corresponding to the destination pixel.
11 ® Intel Image Processing Library Reference Manual Example 11-4 Re-mapping an Image (continued) /// allocate memory destination with zero data iplAllocateImage( dst, 1, 0 ); /// provide the x and y coordinates /// these coords map the image to an identical one for( y=0; y
Image Statistics Functions 12 This chapter describes the Image Processing Library functions that allow you to compute the following statistical parameters of an image: • • • • the C, L1, and L2 norms of the image pixel values spatial moments of order 0 to 3 central moments of order 0 to 3 minimum and maximum pixel values (for floating-point data only) Table 12-1 lists the image statistics functions.
12 ® Intel Image Processing Library Reference Manual Image Norms The iplNorm() function described in this section allows you to compute the following norms of the image pixel values: • L1 norm (the sum of absolute pixel values) • L2 norm (the square root of the sum of squared pixel values) • C norm (the largest absolute pixel value). This function also helps you compute the norm of differences in pixel values of two input images as well as the relative error for two input images.
12 Image Statistics Functions (1) the norm of srcImageA pixel values, ||a|| (2) the norm of differences of the source images’ pixel values, ||a - b|| (3) the relative error ||a - b|| / ||b|| (see formulas below). Let a = {ak} and b = {bk} be vectors containing pixel values of srcImageA and srcImageB, respectively (all channels are used except alpha channel).
12 ® Intel Image Processing Library Reference Manual Example 12-1 Computing the Norm of Pixel Values int example51( void ) { IplImage *imga, *imgb; const int width = 4; const int height = 4; double norm; __try { imga = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALIGN_QWORD, height, width, NULL, NULL, NULL, NULL); if( NULL == imga ) return 0; imgb = iplCreateImageHeader( 1, 0, IPL_DEPTH_8U, "GRAY", "GRAY", IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, IPL_ALI
12 Image Statistics Functions Image Moments Spatial and central moments are important statistical characteristics of an image.
12 ® Intel Image Processing Library Reference Manual Moments Computes all image moments of order 0 to 3. void iplMoments(IplImage* image, IplMomentState mState); image The image for which the moments will be computed. mState The structure for storing the image moments. Discussion The function iplMoments() computes all spatial and central moments of order 0 to 3 for the image. The moments and the corresponding scaling factors are stored in the mState structure.
12 Image Statistics Functions Discussion The function iplGetSpatialMoment() returns the spatial moment MU(m,n) previously computed by the iplMoments() function. GetCentralMoment Returns a central moment computed by iplMoments. double iplGetCentralMoment(IplMomentState mState, int mOrd, int nOrd); mState The structure storing the image moments. mOrd, nOrd The integer exponents m and n (see the moment definition in the beginning of this section).
12 ® Intel Image Processing Library Reference Manual mState The structure storing the image moments. mOrd, nOrd The integer exponents m and n (see the moment definition in the beginning of this section). These arguments must satisfy the condition 0 ≤ mOrd + nOrd ≤ 3.
12 Image Statistics Functions SpatialMoment Computes a spatial moment. double iplSpatialMoment(IplImage* image, int mOrd, int nOrd); image The image for which the moment will be computed. mOrd, nOrd The integer exponents m and n (see the moment definition in the beginning of this section). These arguments must satisfy the condition 0 ≤ mOrd + nOrd ≤ 3. Discussion The function iplSpatialMoment() computes the spatial moment MU(m,n) for the image. CentralMoment Computes a central moment.
12 ® Intel Image Processing Library Reference Manual Discussion The function iplCentralMoment() computes the central moment UU(m,n) for the image. NormalizedSpatialMoment Computes a normalized spatial moment. double iplNormalizedSpatialMoment(IplImage* image, int mOrd, int nOrd); image The image for which the moment will be computed. mOrd, nOrd The integer exponents m and n (see the moment definition in the beginning of this section). These arguments must satisfy the condition 0 ≤ mOrd + nOrd ≤ 3.
12 Image Statistics Functions NormalizedCentralMoment Computes a normalized central moment. double iplNormalizedCentralMoment(IplImage* image, int mOrd, int nOrd); image The image for which the moment will be computed. mOrd, nOrd The integer exponents m and n (see the moment definition in the beginning of this section). These arguments must satisfy the condition 0 ≤ mOrd + nOrd ≤ 3.
12 ® Intel Image Processing Library Reference Manual Cross-Correlation This section describes the iplNormCrossCorr() function that allows you to compute the cross-correlation of an image and a template (another image). The cross-correlation values are image similarity measures: the higher cross-correlation at a particular pixel, the more similarity between the template and the image in the neighborhood of the pixel.
12 Image Statistics Functions NormCrossCorr Computes normalized cross-correlation between an image and a template. IPLStatus iplNormCrossCorr (IplImage* srcImage, IplImage* tplImage, IplImage* dstImage); srcImage, tplImage The source and template images. dstImage The destination image.
12 ® Intel Image Processing Library Reference Manual Minimum and Maximum The iplMinMaxFP() function described in this section allows you to compute the minimum and maximum pixel values for an image with 32-bit floating-point data. MinMaxFP Retrieves the minimum and maximum floatingpoint pixel value. IPLStatus iplMinMaxFP (const IplImage* image, float* min, float* max); image The image with 32-bit floating-point pixel data for which the minimum and maximum values will be retrieved.
User Defined Functions 13 This chapter describes library functions that enable users to create their own image processing functions and make calls to them from application programs. You can define functions that perform point operations either on each channel value of processed pixels of an image separately, or on all channel values simultaneously. Both integer and floating-point image data can be processed.
13 ® Intel Image Processing Library Reference Manual UserFunc The type of user-defined functions that perform point operations on a separate channel value of a pixel (for images with integer data). The prototype specified by the callback function of type IplUserFunc must be as follows: typedef int (__STDCALL *IplUserFunc)(int src); src The source pixel channel value converted to int type.
13 User Defined Functions UserFuncFP The type of user-defined functions that perform point operations on a separate channel value of a pixel (for images with all data types). The prototype specified by the callback function of type IplUserFuncFP must be as follows: typedef float (__STDCALL *IplUserFuncFP)(float src); src The source pixel channel value converted to float type.
13 ® Intel Image Processing Library Reference Manual UserFuncPixel The type of user-defined functions that perform point operations simultaneously on all channel values of a pixel in an image.
13 User Defined Functions If saturation of the computed result is necessary, it must be provided within the user function. The user function of type IplUserFuncPixel may call IPL_ERROR to set the IPL error status. See iplUserProcessPixel() for more information. UserProcess Calls user-defined function to separately process each channel value of pixels in an image with integer data. void iplUserProcess( IplImage* srcImage, IplImage* dstImage, IplUserFunc cbFunc ); srcImage The source image.
13 ® Intel Image Processing Library Reference Manual data. To perform saturation of 32-bit integer data, use iplUserProcessFP() function instead. The function iplUserProcess() supports tiled images and images with rectangle ROI and mask ROI. The operations can be performed in-place. The source and destination images must contain data of the same bit depth and have the same number of processed channels.
13 User Defined Functions UserProcessFP Calls user-defined function to separately process each channel value of pixels in images with all data types. void iplUserProcessFP( IplImage* srcImage, IplImage* dstImage, IplUserFuncFP cbFunc ); srcImage The source image. dstImage The destination image. cbFunc The pointer to the user-defined function (of IplUserFuncFP type).
13 ® Intel Image Processing Library Reference Manual UserProcessPixel Calls user-defined function to simultaneously process channel values of pixels in an image. void iplUserProcessPixel( IplImage* srcImage, IplImage* dstImage, IplUserFuncPixel cbFunc ); srcImage The source image. dstImage The destination image. cbFunc The pointer to the user-defined function (of IplUserFuncPixel type).
User Defined Functions 13 Example 13-2 Pixel Values Processing by User Defined Function static void __STDCALL rgb2gray( IplImage* srcImage, void* srcPixel, IplImage* dstImage, void* dstPixel ) { uchar* src = (uchar*)srcPixel; uchar* dst = (uchar*)dstPixel; if( 1 != dstImage->nChannels ) { IPL_ERROR( IPL_BadNumChannels, "rgb2gray", "Output image must be one-channel image"); return; } dst[0] = (uchar)( 0.212671 * src[0] + 0.71516 * src[1] + 0.072169 * src[2] + 0.
This page is left blank for double-sided printing This page is left blank for double-sided printing
Library Version 14 This chapter describes the function iplGetLibVersion() that returns the version number and other information about the Image Processing Library. GetLibVersion Returns information about the library version.
14 ® Intel Image Processing Library Reference Manual The IPLLibVersion structure is defined as follows: typedef int int int const const const struct _IPLLibVersion { major; /* e.g. 2 */ minor; /* e.g. 0 */ build; /* e.g. 1 */ char * Name; /* "ipl6l.lib","iplm5.dll" */ char * Version; /* e.g. "v2.00" */ char * InternalVersion; /* e.g. "[2.00.01.023,01/01/99]" */ const char * BuildDate; /* e.g.
A Supported Image Attributes and Operation Modes This appendix contains tables that list the supported image attributes and operation modes for functions that have input and/or output images. The ipl prefixes in the function names are omitted. Table A-1 Function Image Attributes and Modes of Data Exchange Functions Input and output images must have the same Depths depth order origin COI Rect.
A ® Intel Image Processing Library Reference Manual Table A-2 Windows DIB Conversion Functions Function Depths input output Input and output images have the same order origin number of channels ConvertFromDIB all‡ 1u,8u,16u ConvertFromDIBSep all‡ ConvertToDIB 1u,8u,16u 1u,8u,16u all‡ x ConvertToDIBSep 1u,8u,16u all‡ x TranslateDIB 1bpp 1u clone x x ≥4bpp‡ 8u clone x x ‡ all = 1, 4, 8, 16, 24, 32 bpp DIB images; ≥4bpp stands for 4, 8, 16, 24, 32 bpp DIB images.
A Supported Image Attributes and Operation Modes Table A-3 Image Attributes and Modes of Arithmetic and Logical Functions Function Depths Input and output images must have the same depth order origin COI Rect.
A ® Intel Image Processing Library Reference Manual Table A-4 Image Attributes and Modes of Alpha-Blending Functions Function Input and output images must have the same Depths depth order origin Rect.
A Supported Image Attributes and Operation Modes Table A-7 Function Image Attributes and Modes of Morphological Operations Input and output images must have the same Depths depth order origin Rect.
A ® Intel Image Processing Library Reference Manual Table A-9 Image Attributes and Modes of Histogram and Thresholding Functions Function Depths Input and output images must have the same depth order origin Threshold 8u,8s,16u, 16s, 32s† ComputeHisto 1u,8u,16u HistoEqualize 8u,16u x x ContrastStretch 8u,16u all‡ x x x x Rect.
A Supported Image Attributes and Operation Modes Table A-11 Image Attributes and Modes of Image Statisctics Functions Function All images must have the same Depths depth order origin Rect.
This page is left blank for double-sided printing This page is left blank for double-sided printing
Interpolation in Geometric Transform Functions B This appendix describes the interpolation algorithms used in the geometric transformation functions of the Image Processing Library. For more information about each of the geometric transform functions, see Chapter 11, Geometric Transforms. Overview of Interpolation Modes In geometric transformations, the grid of input image pixels is not necessarily mapped onto the grid of pixels in the output image.
B ® Intel Image Processing Library Reference Manual Table B-1 lists the supported interpolation modes for all geometric transform functions. For certain functions, you can combine the above interpolation algorithms with additional smoothing (antialiasing) of edges to which the original image’s borders are transformed. To use this edge smoothing, set the parameter interpolate to the bitwise OR of IPL_SMOOTH_EDGE and the desired interpolation mode.
Interpolation in Geometric Transformation Functions B Mathematical Notation In this appendix we’ll use the following notation: (xD,yD) pixel coordinates in the destination image (integer values) (xS, yS) the computed coordinates of a point in the source image that is mapped exactly to (xD,yD) S(x, y) pixel value (intensity) in the source image D(x, y) pixel value (intensity) in the destination image. Nearest Neighbor Interpolation This is the fastest and least accurate interpolation mode.
B ® Intel Image Processing Library Reference Manual Then, the sought-for intensity D(xD,yD) is computed by interpolating the intermediate values I0 and I1 along the y-axis: D(xD,yD) = I0*(yS1 - yS) + I1*(yS – yS0). To use the linear interpolation, set the parameter interpolate to IPL_INTER_LINEAR. For images with 1-bit and 8-bit unsigned color channels, the functions iplWarpAffine, iplRotate, and iplShear compute the coordinates –16 (xS,yS) with the accuracy 2 = 1/65536.
B Interpolation in Geometric Transformation Functions Cubic Interpolation The cubic interpolation algorithm (see Figure B-2) uses source image intensities at sixteen pixels in the neighborhood of the point (xS,yS) in the source image: xS0 = int(xS) - 1 xS1 = xS0 + 1 xS2 = xS0 + 2 xS3 = xS0 + 3 yS0 = int(yS) - 1 yS1 = yS0 + 1 yS2 = yS0 + 2 yS3 = yS0 + 3.
B ® Intel Image Processing Library Reference Manual Figure B-2 Cubic Interpolation intensity F0(x) F1(x) x xS3 F3(x) F2(x) D(xS,yS) xS2 xS1 xS xS0 yS0 yS1 yS yS2 yS3 y Super-Sampling If the destination image is much smaller than the source image, the above interpolation algorithms may skip some pixels in the source image (that is, these algorithms not necessarily use all source pixels when computing the destination pixels’ intensity).
B Interpolation in Geometric Transformation Functions For each source pixel intersecting with the rectangle, Figure B-3 shows the corresponding weight value. (3) To compute the pixel value in the destination image, divide this weighted sum by the rectangle area (xSrc*ySrc)/(xDst*yDst). Here xSrc, xDst, ySrc, and yDst are parameters passed to the functions iplDecimate and iplResize to set the decimation ratios xDst/xSrc and yDst/ySrc.
This page is left blank for double-sided printing This page is left blank for double-sided printing
Bibliography This bibliography provides a list of publications that might be useful to the Image Processing Library users. This list is not complete; it serves only as a starting point. The books [Rogers85], [Rogers90], and [Foley90] are good resources of information on image processing and computer graphics, with mathematical formulas and code examples. ® The Image Processing Library is part of Intel Performance Library Suite.
® Intel Image Processing Library Reference Manual ® [RPL] Intel Recognition Primitives Library Reference Manual. Intel Corp. Order number 637785. [SPL] Intel Signal Processing Library Reference Manual. Intel Corp. Order number 630508. [Schumacher] Dale A. Schumacher. A comparison of digital halftoning techniques, Graphic Gems III: 57–71. [Thomas] Spencer W. Thomas and Rod G. Bogart. Color dithering, Graphic Gems II: 72–77.
Glossary absolute colors alpha channel arithmetic operation channel of interest CMY CMYK COI color-twist matrix conjugate DCT decimation Colors specified by each pixel’s coordinates in a color space. Intel Image Processing Library functions use images with absolute colors. See palette colors. A color channel, also known as the opacity channel, that can be used in color models; for example, the RGBA model. An operation that adds, subtracts, multiplies, shifts, or squares the image pixel values.
® Intel Image Processing Library Reference Manual DIB dilation dyadic operation erosion FFT four-channel model geometric transform functions gray scale image HLS HSV hue Glossary-2 Device-independent bitmap, an image format used by the library in Windows environment. A morphological operation that sets each output pixel to the minimum of the corresponding input pixel and its 8 neighbors. An operation that has two input images. It can have other input parameters as well.
Glossary in-place operation linear filtering linear image transforms luminance LUT LUV MMX TM technology monadic operation morphological operation MSI non-linear filtering opacity channel out-of-place operation An operation whose output image is one of the input images. See out-of-place operation. In this library, either neighborhood averaging (blur) or 2D convolution operations. In this library, the fast Fourier transform (FFT) or the discrete cosine transform (DCT).
® Intel Image Processing Library Reference Manual palette colors PhotoYCC* pixel depth pixel-oriented ordering plane-oriented ordering region of interest RGB RGBA ROI saturation scanline standard gray palette three-channel model Glossary-4 Colors specified by a palette, or lookup table. The Image Processing Library uses palette colors only in operations of image conversion to and from absolute colors. See absolute colors. A Kodak* proprietary color encoding and image compression scheme. See YCC.
Glossary XYZ YCC YUV zoom A three-channel color model designed to represent a wider range of colors than the RGB model: some XYZ-representable colors would have a negative value of R. For conversion formulas, see RGB2XYZ. A three-channel color model that uses one luminance channel (Y) and two chroma channels (usually denoted by CR and CB). The term is sometimes used as a synonym for the entire PhotoYCC encoding scheme. See PhotoYCC. A three-channel color model frequently used in television.
This page is left blank for double-sided printing This page is left blank for double-sided printing
Index compare pixels in two images for equality, 10-15 within tolerance ε, 10-16 A a function that helps you add a constant to pixel values, 5-3 add pixel values of two images, 5-7 allocate a quadword-aligned memory block, 4-27 allocate image data, 4-13 compare pixels in two images for greater than, 10-13 compare pixels in two images for less than, 10-14 compute absolute pixel values, 5-6 compute bitwise AND of pixel values and a constant, 5-12 allocate memory for 16-bit words, 4-28 compute bitwise AND
® Intel Image Processing Library Reference Manual convert a color image to gray scale, 9-8 convert a gray scale image to color, 9-9 free memory allocated by Malloc functions, 4-30 convert images from DIB (changing attributes), 4-50, 4-53 free the image data memory, 4-15 convert images from DIB (preserving attributes), 4-47 get error-handling mode, 3-4 convert images to DIB, 4-54, 4-55 get the value of pixel (x,y), 4-38 convert RGB images to and from other color models, 9-10 handle an error, 3-2,
Index set a region of interest (ROI), 4-22 Add function, 5-7 set error-handling mode, 3-4 adding a constant to pixel values, 5-3 set one pixel to a new value, 4-38 adding pixels of two images, 5-7 set pixels to the maximum value of the neighbors, 6-17 AddS function, 5-3 set pixels to the median value of the neighbors, 6-15 alignment set pixels to the minimum value of the neighbors, 6-18 set the error status code, 3-3 set the image border mode, 4-23 set the IplTileInfo structure fields, 4-26 shear
® Intel Image Processing Library Reference Manual AndS function, 5-12 bitwise OR ApplyColorTwist function, 9-21 with a constant, 5-13 argument order conventions, 1-7 arithmetic operations, 5-1 with another image, 5-15 bitwise XOR Abs, 5-6 with a constant, 5-14 Add, 5-7 with another image, 5-16 AddS, 5-3 Blur function, 6-2 AddSFP, 5-3 brightening the image, 5-3 AlphaComposite, 5-18 AlphaCompositeC, 5-18 C Multiply, 5-8 MultiplyS, 5-4 MultiplyScale, 5-9 MultiplySFP, 5-4 MultiplySScale, 5-5 P
Index DeleteColorTwist, 9-22 computing the norm of pixel values, 12-2 GrayToColor, 9-9 ContrastStretch function, 10-7 HLS2RGB, 9-13 conventions HSV2RGB, 9-12 font, 1-5 LUV2RGB, 9-14 names of constants and variables, 1-6 ReduceBits, 9-3 names of functions, 1-6 RGB2HLS, 9-13 order of arguments, 1-7 RGB2HSV, 9-12 Convert function, 4-36 RGB2LUV, 9-14 ConvertFromDIB function, 4-50 RGB2XYZ, 9-15 ConvertFromDIBSep function, 4-53 RGB2YCrCb, 9-16 converting bitonal images to gray scale, 9-7 RG
® Intel Image Processing Library Reference Manual convolution, 6-3 NoiseUniformInit, 4-43 Convolve2D function, 6-8 NoiseUniformInitFp, 4-43 Convolve2DFP function, 6-8 PutPixel, 4-38 ConvolveSep2D function, 6-11 Scale, 4-40 ConvolveSep2DFP function, 6-11 ScaleFP, 4-41 coordinate systems, 2-4 Set, 4-31 Copy function, 4-32 SetFP, 4-31 copying entire images, 4-15 data ordering, 2-3 copying the image data, 4-32 data ranges in HLS and HSV models, 9-11 CreateColorTwist function, 9-19 data type
Index SetErrStatus, 3-3 E StdErrReport, 3-7 Equal function, 10-15 EqualFPEps function, 10-16 equalizing the image histogram, 10-10 EqualS function, 10-21 ErrorStr function, 3-5 Exchange function, 4-35 execution architecture, 2-8 in-place and out-of-place operations, 2-8 EqualSFP function, 10-22 overflow and underflow, 2-8 EqualSFPEps function, 10-23 saturation, 2-8 Erode function, 8-2 erosion of an image, 8-2 ErrModeLeaf error mode, 3-4 F ErrModeParent error mode, 3-5 fast Fourier and discrete
® Intel Image Processing Library Reference Manual GetConvKernelFP, 6-6 WarpBilinear, 11-20 MaxFilter, 6-17 WarpBilinearQ, 11-20 MedianFilter, 6-15 WarpPerspective, 11-24 MinFilter, 6-18 WarpPerspectiveQ, 11-24 FixedFilter function, 6-12 font conventions, 1-5 Zoom, 11-4 geometric transform macros Free function, 4-30 DecimateFit, 11-8 free memory allocated by Malloc functions, 430 ResizeFit, 11-8 function descriptions, 1-4 function name conventions, 1-6 RotateCenter, 11-13 ZoomFit, 11-8 GetAf
Index Greater function, 10-13 XOR operation, 5-22 GreaterS function, 10-17 image creation functions, 4-1 GreaterSFP function, 10-18 AllocateImage, 4-13 GuiBoxReport function, 3-7 AllocateImageFP, 4-13 CheckImageHeader, 4-17 CloneImage, 4-15 H CreateImageHeader, 4-9 handling overflow and underflow, 2-8 hardware and software requirements, 1-1 HistoEqualize function, 10-10 histogram and thresholding functions, 10-1 ComputeHisto, 10-9 ContrastStretch, 10-7 HistoEqualize, 10-10 Threshold, 10-2 histogra
® Intel Image Processing Library Reference Manual error handling, 3-1 iMalloc function, 4-28 filtering functions, 6-1 IN compositing operation, 5-22 geometric transform functions, 11-1 in-place operations, 2-8 histogram and thresholding functions, 10-1 interpolation algorithms, B-1 image creation, 4-1 IPL_ErrModeLeaf, 3-4 image statistics, 12-1 IPL_ErrModeParent, 3-5 image tiling, 2-8, 4-8 IPL_ErrModeSilent, 3-5 interpolation algorithms, B-1 iplAbs, 5-6 logical operations, 5-1 iplAdd, 5-7
Index iplConvertToDIB, 4-54 iplErode, 8-2 iplConvertToDIBSep, 4-55 iplError, 3-2 iplConvolve2D, 6-8 iplErrorStr, 3-5 iplConvolve2DFP, 6-8 iplExchange, 4-35 iplConvolveSep2D, 6-11 iplFixedFilter, 6-12 iplConvolveSep2DFP, 6-11 iplFree, 4-30 iplCopy, 4-32 iplGetAffineBound, 11-18 iplCreateColorTwist, 9-19 iplGetAffineQuad, 11-18 iplCreateConvKernel, 6-5 iplGetAffineTransform, 11-19 iplCreateConvKernelChar, 6-5 iplGetBilinearBound, 11-22 iplCreateConvKernelFP, 6-5 iplGetBilinearQuad, 11-22
® Intel Image Processing Library Reference Manual Index-12 iplHLS2RGB, 9-13 iplNot, 5-12 iplHSV2RGB, 9-12 iplNullDevReport, 3-7 IplImage structure, 4-7 iplOpen, 8-6 ipliMalloc, 4-28 iplOr, 5-15 IplLastStatus variable, 3-5 iplOrS, 5-13 iplLess, 10-14 iplPreMultiplyAlpha, 5-24 iplLessS, 10-19 iplPutPixel, 4-38 iplLessSFP, 10-20 iplRealFft2D, 7-4 iplLShiftS, 5-10 iplRedirectError, 3-6 iplLUV2RGB, 9-14 iplReduceBits, 9-3 iplMalloc, 4-27 iplRemap, 11-28 iplMaxFilter, 6-17 iplResize, 11-
Index iplsMalloc, 4-29 iplSpatialMoment, 12-9 iplSquare, 5-6 iplStdErrReport, 3-7 iplSubtract, 5-8 iplSubtractS, 5-4 L Less function, 10-14 LessS function, 10-19 LessSFP function, 10-20 linear filters, 6-2 logical operations, 5-1 iplSubtractSFP, 5-4 And, 5-15 iplThreshold, 10-2 AndS, 5-12 IplTileInfo structure, 4-8 LShiftS, 5-10 iplTranslateDIB, 4-47 Not, 5-12 iplUserFunc, 13-2 Or, 5-15 iplUserFuncFP, 13-3 OrS, 5-13 iplUserFuncPixel, 13-4 RShiftS, 5-11 iplUserProcess, 13-5 Xor, 5-16 iplUs
® Intel Image Processing Library Reference Manual iMalloc, 4-28 Multiply function, 5-8 Malloc, 4-27 multiplying and scaling pixel values sMalloc, 4-29 by a constant, 5-5 wMalloc, 4-28 in two input images, 5-9 MinFilter function, 6-18 multiplying pixel values minimum permissible value, 2-8 by a color-twist matrix, 9-21, 9-23 minimum pixel value, 12-14 by a constant, 5-4 MinMaxFP function, 12-14 by a negative power of 2, 5-11 Mirror function, 11-14 in two input images, 5-8 mirroring the im
Index channel, 2-4 O mask image, 2-4 online version of this manual, 1-5 rectangular, 2-4 opacity channel.
® Intel Image Processing Library Reference Manual SetErrStatus function, 3-3 call-backs, 2-9 SetFP function, 4-31 CreateTileInfo function, 4-25 SetROI function, 4-22 DeleteTileInfo function, 4-26 SetTileInfo function, 4-26 IplTileInfo structure, 4-8 Shear function, 11-16 SetTileInfo function, 4-26 shearing the image, 11-16 TranslateDIB function, 4-47 shifting pixel bits two-dimensional convolution, 6-3 to the left, 5-10 to the right, 5-11 U shrinking the image, 11-5, 11-6, 11-7 signed data
Index ConvertFromDIBSep, 4-53 ConvertToDIB, 4-54 ConvertToDIBSep, 4-55 TranslateDIB, 4-47 wMalloc function, 4-28 X XOR compositing operation, 5-22 Xor function, 5-16 XorS function, 5-14 XYZ2RGB function, 9-15 Y YCC2RGB function, 9-18 YCrCb2RGB function, 9-16 YUV2RGB function, 9-17 Z Zoom function, 11-4 ZoomFit macro, 11-8 zooming the image, 11-4, 11-7 Index-17