Syntax
sod_img sod_make_image(int w, int h, int c);
Description
Allocate & zero fill a new sod_img object. Basically, a sod_img is just a record of the width, height, and number of channels in an image, and also the pixel values for every pixel. Images pixels are arranged in CHW format. This means in a 3 channel image with width 400 and height 300, the first 400 values are the 1st row of the 1st channel of the image. The second 400 pixels are the 2nd row. after 120,000 values we get to pixels in the 2nd channel, and so forth.
Raw pixels values can be manipulated via a set of public interfaces such as sod_img_add_pixel(), sod_img_get_pixel(), sod_img_set_pixel(), etc. or directly via the data pointer member of this structure. In that case, you have to be careful of the target pixel location that must be in range unlike the exposed public interfaces that take care of checking range location for you.
Parameters
int w
Image width.
int h
Image height.
int c
Total number of desired color channels (i.e 1 for grayscale image, 3 for standard BGR/RGB/YuV/HSV image).
Return Value
Allocated & ready to use sod_img object. if something goes wrong during allocation (i.e. running out-of-memory), then an empty image is returned via sod_make_empty_image(). Once done, you must release the memory allocated to this object via sod_free_image() to avoid memory leaks.
Example
Checkout the introduction course, the C/C++ samples on the download page or refer to the SOD Github Repository.
See also
sod_canny_edge_image • sod_image_draw_box • sod_hilditch_thin • sod_hough_lines_detect • sod_free_image • sod_img_get_pixel.