BRL-CAD

Functions provided by the LIBICV image processing library for reading and writing of images. More...

Collaboration diagram for Image Read/Write:

Files

file  io.h
 

Functions

icv_image_ticv_create (size_t width, size_t height, ICV_COLOR_SPACE color_space)
 
icv_image_ticv_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_ticv_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)
 

Detailed Description

Functions provided by the LIBICV image processing library for reading and writing of images.

Function Documentation

◆ icv_create()

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.

Parameters
widthWidth of the image to be created
heightHeight of the image to be created
color_spaceColor space of the image (RGB, grayscale)
Returns
Image structure with allocated space and zeroed data array

◆ icv_zero()

icv_image_t * icv_zero ( icv_image_t bif)

This function zeroes all the data entries of an image

Parameters
bifImage Structure

◆ icv_destroy()

int icv_destroy ( icv_image_t bif)

This function frees the allocated memory for a ICV Structure and data.

◆ icv_image_size()

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.

Parameters
[in]labelString hinting at a size (pass NULL if not using)
[in]dpiDots per inch of image (pass 0 if not using)
[in]data_sizeNumber of uncompressed image bytes (necessary if deducing an unspecified image size)
[in]typeImage type (necessary if deducing an unspecified image size)
[out]widthpPointer to variable that will hold image width
[out]heightpPointer to variable that will hold image height
Returns
Returns 1 if an image size was identified, zero otherwise.

◆ icv_read()

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

Parameters
filenameFile to read
formatProbable format of the file, typically ICV_IMAGE_AUTO
widthWidth when passed as parameter from calling program.
heightHeight when passed as parameter from calling program.
Returns
A newly allocated struct holding the loaded image info.

◆ icv_write()

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.

Parameters
bifImage structure of file.
filenameFilename of the file to be written.
formatSpecific format of the file to be written.
Returns
on success 0, on failure -1 with log messages.

◆ icv_writeline()

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.

Parameters
bifICV struct where data is to be written
yIndex of the line at which data is to be written. 0 for the first line
dataLine Data to be written
typeType of data, e.g., uint8 data specify ICV_DATA_UCHAR or 1
Returns
on success 0, on failure -1

◆ icv_writepixel()

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.

Parameters
bifICV struct where data is to be written
xx-dir coordinate of the pixel
yy-dir coordinate of the pixel. (0,0) coordinate is taken as bottom left
dataData to be written
Returns
on success 0, on failure -1

◆ icv_data2uchar()

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.

Parameters
bifICV struct where data is to be read from
Returns
array of unsigned char converted data, or NULL on failure

◆ icv_uchar2double()

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.

Parameters
datapointer to the array to be converted.
sizeSize of the array.
Returns
double array.