2D image class.
Macros:
Definition of the dimensions of an image
Definition of a position in the image (from left to right and top to bottom)
Shortcuts for CapyImgCreate()
Shortcuts for CapyImgAlloc()
Enumerations:
Enumeration of image modes
Enumeration to identify the neighours of a pixel
Enumeration for the types of iterator on a CapyImg
Typedefs:
Type for the size of an image
Dimensions of an image
Type to store a pixel coordinate
Position in the image (from left to right and top to bottom)
CapyImg object predeclaration
Struct CapyImgPixel :
Struct CapyImgPixel's properties:
Position
Index in the array of pixels
Color data
Struct CapyImgPixel's methods:
None.
Struct CapyImgIterator :
Struct CapyImgIterator's properties:
Index of the current step in the iteration
Returned data type
Current pixel of the iteration
Type of iteration
Image associated to the iteration
Struct CapyImgIterator's methods:
Destructor
Reset the iterator
Output and side effect(s):
Return the first pixel of the iteration
Move the iterator to the previous pixel
Output and side effect(s):
Return the previous pixel of the iteration
Move the iterator to the next pixel
Output and side effect(s):
Return the next pixel of the iteration
Check if the iterator is on a valid pixel
Output and side effect(s):
Return true if the iterator is on a valid pixel, else false
Get the current pixel of the iteration
Output and side effect(s):
Return a pointer to the current pixel
Set the type of the iterator and reset it
Input argument(s):
type: the new type of the iterator
Struct CapyImg :
Struct CapyImg's properties:
Array of pixel colors, stored by rows from top to bottom and left to right
Mode of the image
Dimensions of the image
Iterator on pixels
Display gamma (by default 2.2, equivalent to a standard PC monitor) i.e.: (displayed RGB) = (file RGB)^(display gamma)
Color space to interpret the pixels values (default: sRGB)
Struct CapyImg's methods:
Destructor
Get the color of a pixel at a given position
Input argument(s):
pos: the position of the pixel
Output and side effect(s):
Return the color of the pixel
Set the color of a pixel at a given position
Input argument(s):
pos: the position of the pixel
color: the color to set
Initialise the iterator of the image, must be called after the creation of the image when it is created with Create(), Alloc() automatically initialise the iterator.
Check if coordinates are inside the image
Input argument(s):
coord: the coordinates to check
Output and side effect(s):
Return true if the coordinates are inside the image, else false
Copy another image in the image
Input argument(s):
img: the image to copy (must be of same dimensions)
Get the number of pixels
Output and side effect(s):
Return the number of pixels
Change the gamma encoding of the image. Pixels value are updated.
Input argument(s):
gamma: the new gamma value
Get the brightest pixel in the image
Output and side effect(s):
Return the brightest (maximum r+g+b) pixel.
Get an edge map of the image.
Input argument(s):
kernelSize: the size in pixel of the gaussian blur kernel, the higher the less sensitive
stdDev: the standard deviation of the gaussian blur (as a guide, kernelSize = 4 * stdDev)
iChannel: index of the channel used for edge detection
Output and side effect(s):
Return an image of same dimensions where pixel values represent the 'flatness' of the image. The red channel is the norm of the derivative gaussian blur in x and y direction. The green and blue channels contain the x and y coordinates of the normalised vector indicating the direction of the slope (going up), the alpha channel is set to 1.0.
Exception(s):
May raise CapyExc_MallocFailed.
Get an edge map of the image based on its first 3 channels.
Input argument(s):
kernelSize: the size in pixel of the gaussian blur kernel, the higher the less sensitive
stdDev: the standard deviation of the gaussian blur (as a guide, kernelSize = 4 * stdDev)
Output and side effect(s):
Use getEdgeMap() to calculate the edge map for each of the three first channels of the image and combined them into one single edge map by choosing for each pixel the values in the edge map with maximum slope at that pixel.
Exception(s):
May raise CapyExc_MallocFailed.
Get an edge map of the image based on one given channel using the Canny edge detection method.
Input argument(s):
iChan: the channel to use
kernelSize: the size in pixel of the gaussian blur kernel, the higher the less sensitive
stdDev: the standard deviation of the gaussian blur (as a guide, kernelSize = 4 * stdDev)
hysteresisLow, hysteresisHigh: the thresholds for the hysteresis phase, in [0.0, 1.0] and scaled to the maximum intensity after local maximum search phase
Output and side effect(s):
Return an image of same dimension as 'that', where white pixels indicates an edge
Exception(s):
May raise CapyExc_MallocFailed.
Get an edge map of the image based on its first 3 channels using the Canny edge detection method.
Input argument(s):
kernelSize: the size in pixel of the gaussian blur kernel, the higher the less sensitive
stdDev: the standard deviation of the gaussian blur (as a guide, kernelSize = 4 * stdDev)
hysteresisLow, hysteresisHigh: the thresholds for the hysteresis phase, in [0.0, 1.0] and scaled to the maximum intensity after local maximum search phase
Output and side effect(s):
Return an image of same dimension as 'that', where white pixels indicates an edge
Exception(s):
May raise CapyExc_MallocFailed.
Get an edge map of the image based on its first 3 channels using the local maximum gradient method.
Input argument(s):
kernelSize: the size in pixel of the gaussian blur kernel, the higher the less sensitive
stdDev: the standard deviation of the gaussian blur (as a guide, kernelSize = 4 * stdDev)
threshold: minimum gradient to be marked as an edge, in [0, 1] of the maximum gradient
Output and side effect(s):
Return an image of same dimension as 'that', where white pixels indicates an edge
Exception(s):
May raise CapyExc_MallocFailed.
Convert an image to greyscale. RGB channel are replaced with (r+g+b)/3
Convert the image to black and white. The image is supposed to be in greyscale, hence the conversion is based on 'pixel.color.intensity'. The RGB channels are replaced by 0.0 if intensity is less threshold and by 1.0 else.
Input argument(s):
threshold: the threshold for the conversion
Convert the image to another color space
Input argument(s):
colorSpace: the target color space
Clean up the values of the pixel to ensure they are in the [0, 1] range.
Get the neighbour pixel of a given pixel in a given direction
Input argument(s):
pixel: the pixel
Output and side effect(s):
Return a pixel. If it's outside the image, its color property is NULL and other properties are undefined.
Set the three first channel values to the value of one of them
Input argument(s):
iChan: the channel to be copied to the other channels
Normalise the image over the 3 first channels of pixels' color.
Normalise the image per pixels' color channel.
Get the colors used in the image as a point cloud
Output and side effect(s):
Return a CapyPointCloud of dimension 4 (all color channels are used).
Exception(s):
May raise CapyExc_MallocFailed.
Check if the image is identical to another
Input argument(s):
img: the other image
Output and side effect(s):
Return true if the images are identical (difference of color values within 1/255), else false.
Save the image to a given path
Input argument(s):
path: the path where to save
Output and side effect(s):
The image is saved.
Exception(s):
May raise CapyExc_UnsupportedFormat.
Functions:
Create an iterator on a CapyImg
Input argument(s):
img: the image on which to iterate
type: the type of iterator
Output and side effect(s):
Return the iterator
Allocate memory and create an iterator on a CapyImg
Input argument(s):
img: the image on which to iterate
type: the type of iterator
Output and side effect(s):
Return the iterator
Free the memory used by a pointer to an iterator and reset '*that' to NULL
Input argument(s):
that: a pointer to the iterator to free
Create a CapyImg of given dimensions and mode
Input argument(s):
mode: mode of the image
dims: dimensions of the image
Output and side effect(s):
Return a CapyImg initialised to rgba opaque white
Exception(s):
May raise CapyExc_MallocFailed.
Allocate memory for a new CapyImg and create it
Input argument(s):
mode: mode of the image
dims: dimensions of the image
Output and side effect(s):
Return a CapyImg initialised to rgba opaque white
Exception(s):
May raise CapyExc_MallocFailed.
Load an image to a given path
Input argument(s):
path: the path to the image
Output and side effect(s):
Return a new image.
Exception(s):
May raise CapyExc_MallocFailed, CapyExc_UnsupportedFormat.
Allocate memory and create a clone of an image
Input argument(s):
img: the image to clone
Output and side effect(s):
Return a clone of the image in argument
Exception(s):
May raise CapyExc_MallocFailed.
Free the memory used by a CapyImg* and reset '*that' to NULL
Input argument(s):
that: a pointer to the CapyImg to free