SOD C/C++ API Reference - Image Processing


Syntax

void sod_free_image(sod_img input);

Description

Release the resources allocated to a sod_img object. This interface must be called each time you have done working with a sod_img object in order to avoid memory leaks.

Parameters

sod_img    input

sod_img object that is to be released. The image can be loaded from disk using sod_img_load_from_file(), from memory (i.e. network socket) via sod_img_load_from_mem(), dynamically created via sod_make_image() or returned from any image processing interfaces such as sod_canny_edge_image() and so forth.

Return Value

None.

Example

/*
* Programming introduction with the SOD Embedded Image Processing API.
* Copyright (C) PixLab | Symisc Systems, https://sod.pixlab.io
*/
/*
* Compile this file together with the SOD embedded source code to generate
* the executable. For example:
*
* gcc sod.c dilate_image.c -lm -Ofast -march=native -Wall -std=c99 -o sod_img_proc
*
* Under Microsoft Visual Studio (>= 2015), just drop `sod.c` and its accompanying
* header files on your source tree and you're done. If you have any trouble
* integrating SOD in your project, please submit a support request at:
* https://sod.pixlab.io/support.html
*/
/*
* This simple program is a quick introduction on how to embed and start
* experimenting with SOD without having to do a lot of tedious
* reading and configuration.
*
* Make sure you have the latest release of SOD from:
* https://pixlab.io/downloads
* The SOD Embedded C/C++ documentation is available at:
* https://sod.pixlab.io/api.html
*/
#include <stdio.h>
#include "sod.h"
/*
* Perform dilation on an input binary image.
*/
int main(int argc, char *argv[])
{
/* Input image (pass a path or use the test image shipped with the samples ZIP archive) */
const char *zInput = argc > 1 ? argv[1] : "./text.jpg";
/* Processed output image path */
const char *zOut = argc > 2 ? argv[2] : "./out_dilated.png";
/* Load the input image in the grayscale colorspace */
sod_img imgIn = sod_img_load_grayscale(zInput);
if (imgIn.data == 0) {
/* Invalid path, unsupported format, memory failure, etc. */
puts("Cannot load input image..exiting");
return 0;
}
/*
* Binarize the input image before the dilation process.
*/
sod_img binImg = sod_binarize_image(imgIn, 0);
/* Finally, dilate the binary image, say 12 times */
sod_img dilImg = sod_dilate_image(binImg, 12);
/* Save the dilated image on the specified path */
sod_img_save_as_png(dilImg, zOut);
/* Cleanup */
sod_free_image(imgIn);
sod_free_image(binImg);
sod_free_image(dilImg);
return 0;
}

Checkout the introduction course, the C/C++ samples on the download page or refer to the SOD Github Repository.

See also

sod_canny_edge_imagesod_image_draw_boxsod_hilditch_thinsod_hough_lines_detectsod_crop_imagesod_composite_image.



Back