SOD C/C++ API Reference - Image Processing


Syntax

int sod_image_find_blobs(sod_img input, sod_box **paBox, int *pnBox, int(*xFilter)(int width, int height));

Description

Perform connected component labeling on an input binary image which is useful for finding blobs (i.e. bloc of texts). The target image must be binary (i.e. images whose pixels have only two possible intensity value mostly black or white). You can obtain a binary image via sod_canny_edge_image(), sod_otsu_binarize_image(), sod_binarize_image() or sod_threshold_image(). When done, you can draw the blob regions via sod_image_draw_bbox() and you must release the sod_box array returned by this call via sod_image_blob_boxes_release() to avoid memory leaks. A typical input image after processing should look like the following:

Binarized via sod_threshold_image() and dilated via sod_dilate_image()

pic via canny_edge

Detected blobs

pic after blob detection

Parameters

sod_img    input

The input image to be processed which must be binary. 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() or dynamically created via sod_make_image().

sod_box    **paBox

OUT: A sod_box array holding the coordinates for each detected blob region is copied into an instance of this pointer on success. if something goes wrong during processing, NULL is copied instead. Once done, you must release the memory allocated to this array via sod_image_blob_boxes_release() to avoid memory leaks.

int    *pnBox

OUT: Total number of detected blob regions.

int    (*xFilter)(int width, int height)

Optional/IN: Filter callback if any to discard blobs not in the expected size. You should rely on the width & height parameters and return a value different from 0 to allow this blob (i.e. record its coordinates). Otherwise it is discarded. Pass NULL in case you want to record everything instead.

Return Value

SOD_OK is returned on success and the sod_box array is filled accordingly. Any other error code indicates failure.

Example

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

See also

sod_sobel_imagesod_image_draw_bboxsod_dilate_imagesod_canny_edge_imagesod_crop_imagesod_hilditch_thin.

Back