BRL-CAD
|
Functions provided by the LIBICV image processing library for reading and writing of images. More...
Files | |
file | io.h |
Functions | |
icv_image_t * | icv_create (size_t width, size_t height, ICV_COLOR_SPACE color_space) |
icv_image_t * | icv_zero (icv_image_t *bif) |
int | icv_destroy (icv_image_t *bif) |
int | icv_image_size (const char *label, size_t dpi, size_t data_size, bu_mime_image_t type, size_t *widthp, size_t *heightp) |
icv_image_t * | icv_read (const char *filename, bu_mime_image_t format, size_t width, size_t height) |
int | icv_write (icv_image_t *bif, const char *filename, bu_mime_image_t format) |
int | icv_writeline (icv_image_t *bif, size_t y, void *data, ICV_DATA type) |
int | icv_writepixel (icv_image_t *bif, size_t x, size_t y, double *data) |
unsigned char * | icv_data2uchar (const icv_image_t *bif) |
double * | icv_uchar2double (unsigned char *data, size_t size) |
Functions provided by the LIBICV image processing library for reading and writing of images.
icv_image_t * icv_create | ( | size_t | width, |
size_t | height, | ||
ICV_COLOR_SPACE | color_space | ||
) |
This function allocates memory for an image and returns the resultant image.
width | Width of the image to be created |
height | Height of the image to be created |
color_space | Color space of the image (RGB, grayscale) |
icv_image_t * icv_zero | ( | icv_image_t * | bif | ) |
This function zeroes all the data entries of an image
bif | Image Structure |
int icv_destroy | ( | icv_image_t * | bif | ) |
This function frees the allocated memory for a ICV Structure and data.
int icv_image_size | ( | const char * | label, |
size_t | dpi, | ||
size_t | data_size, | ||
bu_mime_image_t | type, | ||
size_t * | widthp, | ||
size_t * | heightp | ||
) |
Function to calculate (or make an educated guess) about the dimensions of an image, when the image doesn't supply such information.
Standard image sizes may be hinted using the label parameter. Many standard print and display sizes (e.g., "A4" and "SVGA") are recognized and used in concert with the dpi and data_size parameters.
[in] | label | String hinting at a size (pass NULL if not using) |
[in] | dpi | Dots per inch of image (pass 0 if not using) |
[in] | data_size | Number of uncompressed image bytes (necessary if deducing an unspecified image size) |
[in] | type | Image type (necessary if deducing an unspecified image size) |
[out] | widthp | Pointer to variable that will hold image width |
[out] | heightp | Pointer to variable that will hold image height |
icv_image_t * icv_read | ( | const char * | filename, |
bu_mime_image_t | format, | ||
size_t | width, | ||
size_t | height | ||
) |
Load a file into an ICV struct. For most formats, this will be called with format=ICV_IMAGE_AUTO.
The data is packed in icv_image struct in double format with varied channels as per the specification of image to be loaded.
To read stream from stdin pass NULL pointer for filename.
In case of bw and pix image if size is unknown pass 0 for width and height. This will read the image till EOF is reached. The image size of the output image will be : height = 1; width = size; where size = total bytes read
filename | File to read |
format | Probable format of the file, typically ICV_IMAGE_AUTO |
width | Width when passed as parameter from calling program. |
height | Height when passed as parameter from calling program. |
int icv_write | ( | icv_image_t * | bif, |
const char * | filename, | ||
bu_mime_image_t | format | ||
) |
Saves Image to a file or streams to stdout in respective format
To stream it to stdout pass NULL pointer for filename.
bif | Image structure of file. |
filename | Filename of the file to be written. |
format | Specific format of the file to be written. |
int icv_writeline | ( | icv_image_t * | bif, |
size_t | y, | ||
void * | data, | ||
ICV_DATA | type | ||
) |
Write an image line to the data of ICV struct. Can handle unsigned char buffers.
Note : This function requires memory allocation for ICV_UCHAR_DATA, which in turn acquires BU_SEM_SYSCALL semaphore.
bif | ICV struct where data is to be written |
y | Index of the line at which data is to be written. 0 for the first line |
data | Line Data to be written |
type | Type of data, e.g., uint8 data specify ICV_DATA_UCHAR or 1 |
int icv_writepixel | ( | icv_image_t * | bif, |
size_t | x, | ||
size_t | y, | ||
double * | data | ||
) |
Writes a pixel to the specified coordinates in the data of ICV struct.
bif | ICV struct where data is to be written |
x | x-dir coordinate of the pixel |
y | y-dir coordinate of the pixel. (0,0) coordinate is taken as bottom left |
data | Data to be written |
unsigned char * icv_data2uchar | ( | const icv_image_t * | bif | ) |
Converts double data of icv_image to unsigned char data. This function also does gamma correction using the gamma_corr parameter of the image structure.
Gamma correction prevents bad color aliasing.
bif | ICV struct where data is to be read from |
double * icv_uchar2double | ( | unsigned char * | data, |
size_t | size | ||
) |
Converts unsigned char array to double array. This function returns array of double data.
Used to convert data from pix, bw, ppm type images for icv_image struct.
This does not free the char data.
data | pointer to the array to be converted. |
size | Size of the array. |