easimage
Functions
Image operations

Functions to create and process image structures. More...

Functions

ImageimgNew (unsigned int width, unsigned int height, unsigned short depth)
 Creates a new image. More...
 
ImageimgFromBitmap (const char *filename)
 Loads an image from a BMP image file. More...
 
ImageimgFromPPM (const char *filename)
 Loads an image from a PPM image file. More...
 
ImageimgFromFile (const char *filename)
 
int imgSavePPM (Image *img, char *fname)
 
int imgSavePAM (Image *img, char *fname)
 
int imgSaveRAW (Image *img, char *fname)
 Save RAW file. More...
 
ImageimgCopy (Image *img)
 Creates a copy of an Image. More...
 
void imgScale (Image *img, unsigned int sfactor)
 Scales an image.
 
ImageimgCrop (Image *img, int x1, int y1, int x2, int y2)
 Crops an image. More...
 
ImageimgCreateGaussian (int dim, float sig)
 
ImageimgConvolution (Image *img1, Image *img2, Image *res)
 Image convolution. More...
 
int imgFindPattern (Image *img, Image *pat, int *best_x, int *best_y)
 Searches image for a pattern. More...
 
int imgFindPatternArea (Image *img, Image *pat, int x1, int y1, int x2, int y2, int *best_x, int *best_y)
 Searches image area for a pattern. More...
 
void imgDestroy (Image *img)
 Destroys the image.
 
void imgMakeSymmetricX (Image *img)
 
void imgMakeSymmetricY (Image *img)
 
void imgMakeSymmetric (Image *img)
 
int imgGetSymmetryError (Image *img, int x, int y, int radius)
 Evaluates simmetry error at location. More...
 
ImageimgPatternDifference (Image *img, Image *pat, Image *res, int x1, int y1, int x2, int y2)
 Searches image for a pattern. More...
 
int imgGetPixelDifference (unsigned char *p1, unsigned char *p2)
 
int imgGetSumArea (Image *img, int x1, int y1, int x2, int y2)
 Evaluates the addition of pixel components. More...
 
float imgGetMeanArea (Image *img, int x1, int y1, int x2, int y2)
 Evaluates the pixel component mean value. More...
 
float imgGetMean (Image *img)
 Evaluates the pixel component mean value. More...
 
unsigned int imgGetWidth (Image *img)
 
unsigned int imgGetHeight (Image *img)
 
void imgSetPixel (Image *img, unsigned int x, unsigned int y, unsigned char *pdata)
 
void imgSetPixelRGB (Image *img, unsigned int x, unsigned int y, unsigned char r, unsigned char g, unsigned char b)
 
void imgSetPixelRGBA (Image *img, unsigned int x, unsigned int y, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
 
unsigned char * imgGetPixel (Image *img, unsigned int x, unsigned int y)
 Gets pixel data. More...
 
unsigned char * imgPixel (Image *img, unsigned int x, unsigned int y)
 
void MarkImagePositionRGB (Image *img, int x, int y, unsigned char r, unsigned char g, unsigned char b)
 
void MarkImagePosition (Image *img, int x, int y)
 
int imgGetSymmetricError (Image *img, int x1, int x2, int y1, int y2)
 

Detailed Description

Functions to create and process image structures.

Function Documentation

◆ imgConvolution()

Image * imgConvolution ( Image img1,
Image img2,
Image res 
)

Image convolution.

Performs a convolution beteween Image img1 and Image img2. Convolution result is stored in preallocated Image res. Image res should have dimensions and depth matching Image img1. If res equals NULL, a new Image is allocated. Implementation is optimized for img1 larger than img2. This is usually adequated for processing Image img1 through kernel Image img2. Image img2 should have odd dimensions. Image img2 must use a pixel depth of 8 bits or the same pixel depth as Image img1.

Parameters
imgLocation of Image structure
xNumber of pixel columns
yNumber of pixel rows
Returns
The convolution resulting Image.

◆ imgCopy()

Image * imgCopy ( Image img)

Creates a copy of an Image.

Creates a new image storing a copy of an original Image. Created Image can then be released by calling the imgDestroy() function.

Parameters
imgthe source Image (Image to crop)
Returns
The address of the new copied Image

◆ imgCrop()

Image * imgCrop ( Image img,
int  x1,
int  y1,
int  x2,
int  y2 
)

Crops an image.

Copies a rectangular area to a new Image. Image is created with undefined colors. Image can then be released by calling the imgDestroy() function.

Parameters
imgthe source Image (Image to crop)
x1the column number of first vertex
y1the row number of first vertex
x2the column number of second vertex
y2the row number of second vertex
Returns
The address of the new cropped Image

◆ imgFindPattern()

int imgFindPattern ( Image img,
Image pat,
int *  best_x,
int *  best_y 
)

Searches image for a pattern.

Searches the full specified area from Image img for ocurrences of pattern Image pat. Selectes and informs the location of the best matching pattern.

Parameters
imgImage to be searched.
patImage pattern to search for.
best_xlocation to store the column number of the selected location.
best_ylocation to store the row number of the selected location.
Returns
The matching error for the selected location.

◆ imgFindPatternArea()

int imgFindPatternArea ( Image img,
Image pat,
int  x1,
int  y1,
int  x2,
int  y2,
int *  best_x,
int *  best_y 
)

Searches image area for a pattern.

Searches the full specified area from Image img for ocurrences of pattern Image pat. Selectes and informs the location of the best matching pattern.

Parameters
imgImage to be searched.
patImage pattern to search for.
x1the column number of the top left corner of the image area to be searched
y1the row number of the top left corner of the image area to be searched
x2the column number of the bottom right corner of the image area
y2the row number of the bottom right corner of the image area to be searched
best_xlocation to store the column number of the selected location.
best_ylocation to store the row number of the selected location.
Returns
The matching error for the selected location.

◆ imgFromBitmap()

Image * imgFromBitmap ( const char *  filename)

Loads an image from a BMP image file.

Creates a new Image using the data read from the specified BMP image file. Image can then be released by calling imgDestroy() function.

Parameters
filenamethe name of the BMP image file
Returns
The address of the new loaded Image

◆ imgFromPPM()

Image * imgFromPPM ( const char *  filename)

Loads an image from a PPM image file.

Creates a new Image using the data read from the specified PPM image file. Image can then be released by calling imgDestroy() function.

Parameters
filenamethe name of the PPM image file
Returns
The address of the new loaded Image

◆ imgGetMean()

float imgGetMean ( Image img)

Evaluates the pixel component mean value.

Evaluates the mean value from all (color) components and all pixels within the Image img.

Parameters
imgImage to be processed.
Returns
the calculated mean value as a float

◆ imgGetMeanArea()

float imgGetMeanArea ( Image img,
int  x1,
int  y1,
int  x2,
int  y2 
)

Evaluates the pixel component mean value.

Evaluates the mean value from all (color) components and all pixel within the specified area of the Image img.

Parameters
imgImage to be processed.
x1the column number of the top left corner of the image area to be processed
y1the row number of the top left corner of the image area to be processed
x2the column number of the bottom right corner of the image area to be processed
y2the row number of the bottom right corner of the image area to be processed
Returns
the calculated mean value as a float

◆ imgGetPixel()

unsigned char * imgGetPixel ( Image img,
unsigned int  x,
unsigned int  y 
)

Gets pixel data.

Returns a pointer to the pixel data

Parameters
imgImage structure location
xpixel column number
ypixel row number
Returns
A pointer to the pixel data array

◆ imgGetSumArea()

int imgGetSumArea ( Image img,
int  x1,
int  y1,
int  x2,
int  y2 
)

Evaluates the addition of pixel components.

Evaluates the total addition of all (color) components' values from all pixels within the specified area of the Image img.

Parameters
imgImage to be processed.
x1the column number of the top left corner of the image area to be processed
y1the row number of the top left corner of the image area to be processed
x2the column number of the bottom right corner of the image area to be processed
y2the row number of the bottom right corner of the image area to be processed
Returns
The calculated total value as an int

◆ imgGetSymmetryError()

int imgGetSymmetryError ( Image img,
int  x,
int  y,
int  radius 
)

Evaluates simmetry error at location.

Evaluates the simmetry error of an image's square area. Computed error will be zero if the squre area is fully simmetric along the X and Y axis.

Parameters
imgImage to be processed
xthe column number of the image area to be evaluated
ythe row number of the image area to be evaluated
radiusthe half side dimension of the square area
Returns
The total simmetry error

◆ imgNew()

Image * imgNew ( unsigned int  width,
unsigned int  height,
unsigned short  depth 
)

Creates a new image.

Allocates a memory block to store an Image structure. Image is created with undefined colors. Image can then be released by calling imgDestroy() function.

Parameters
widththe number of columns
heightthe number of rows
depththe pixel size in bits
Returns
The address of the new allocated Image

◆ imgPatternDifference()

Image * imgPatternDifference ( Image img,
Image pat,
Image res,
int  x1,
int  y1,
int  x2,
int  y2 
)

Searches image for a pattern.

Searches full specified area from Image img for ocurrences of pattern Image pat. Produces resulting Image res with calculated differences.

Parameters
imgImage to be searched.
patImage pattern to search for.
resPreviously allocated Image where resulting differences will be stored. If res equals NULL, a new Image is created.
x1the column number of the top left corner of the image area to be searched
y1the row number of the top left corner of the image area to be searched
x2the column number of the bottom right corner of the image area
y2the row number of the bottom right corner of the image area to be searched
Returns
the address of the resulting Image

◆ imgSaveRAW()

int imgSaveRAW ( Image img,
char *  fname 
)

Save RAW file.

Creates (or overwrites) a new file to store Image img. Image is stored in RAW format, without any header or metadata.

Parameters
imgImage to be stored.
fnameName of the destination file.
Returns
0 on success and 1 on error.