SqueezeBrains SDK 1.18
Blob

Blob analysis. More...

Collaboration diagram for Blob:

Data Structures

struct  sb_t_blob_par
 Defines the parameters for blob analysis. More...
 
struct  sb_t_blobs_info
 Defines the information about the blob analysis. More...
 
struct  sb_t_blob
 Defines a blob. More...
 
struct  sb_t_blobs
 Defines a blobs list. More...
 

Enumerations

enum  sb_t_pixel_connection { SB_PIXEL_CONNECTION_4 = 0 , SB_PIXEL_CONNECTION_8 }
 Defines the pixel connection. More...
 
enum  sb_t_blob_distance_mode { SB_BLOB_DISTANCE_MODE_BOUNDING_BOX = 0 , SB_BLOB_DISTANCE_MODE_CONTOUR }
 Enumerates the algorithm for calculating the distance between blobs. More...
 
enum  sb_t_blob_deleted { SB_BLOB_OK = 0 , SB_BLOB_DELETED_BEFORE_MERGE , SB_BLOB_DELETED_AFTER_MERGE }
 Defines the deleted blob. More...
 

Functions

sb_t_err sb_blobs_create (sb_t_blobs **const blobs)
 Creates the blobs structure. More...
 
sb_t_err sb_blob_init_par (sb_t_blob_par *const par)
 Initializes the fields of the structure. More...
 
sb_t_err sb_blob_format_par (int *const c, char *const str, int str_size, int indentation, const sb_t_blob_par *const par)
 Formats the blob analysis parameters structure. More...
 
sb_t_err sb_blobs_detection (sb_t_blobs **const blobs, const sb_t_image *const image, const sb_t_roi *const roi, const sb_t_blob_par *const par, sb_t_image_circularity_type circularity_type)
 Blob analysis. More...
 
sb_t_err sb_blob_intersect (const sb_t_blob *const blob1, const sb_t_blob *const blob2, int extract_blob_seg, sb_t_blob **const res)
 Blob intersection. More...
 
sb_t_err sb_blobs_plot_roi (const sb_t_blobs *const blobs, sb_t_roi *const roi, unsigned char gl)
 Prints the blobs on the roi. More...
 
sb_t_err sb_blob_plot_roi (const sb_t_blob *const blob, sb_t_roi *const roi, unsigned char gl)
 Prints the blob on the roi. More...
 
sb_t_err sb_blobs_clone (sb_t_blobs **const dst, const sb_t_blobs *const src)
 Blobs structure clone. More...
 
sb_t_err sb_blobs_destroy (sb_t_blobs **const blobs)
 Destroys the blobs structure. More...
 
sb_t_err sb_blob_destroy (sb_t_blob *const blob)
 Destroys the blob. More...
 
sb_t_err sb_blob_copy (sb_t_blob *const dst, const sb_t_blob *const src)
 Blob copy. More...
 

Detailed Description

Blob analysis.

Enumeration Type Documentation

◆ sb_t_blob_deleted

Defines the deleted blob.

The values are 32 bits both for 32 and 64 bits library version.

Enumerator
SB_BLOB_OK 

Blob is not deleted.

SB_BLOB_DELETED_BEFORE_MERGE 

Blob is deleted before merge.

SB_BLOB_DELETED_AFTER_MERGE 

Blob is deleted after merge.

Definition at line 9431 of file sb.h.

◆ sb_t_blob_distance_mode

Enumerates the algorithm for calculating the distance between blobs.

In the case of irregular or rotated shapes the distance based on the contour and that based on the bounding box give very different results. In the figure below, the blobs are shown in red and their bounding boxes in green. The difference between the two types of measurement is clearly seen. In the case on the right the bounding boxes intersect so their distance is zero while based on the boundaries the blobs are at a certain distance.

Blobs distance
Enumerator
SB_BLOB_DISTANCE_MODE_BOUNDING_BOX 

The distance between blobs is calculated using the unrotated bounding box.

SB_BLOB_DISTANCE_MODE_CONTOUR 

The distance between blobs is calculated using the contour.

It is possible to select this mode only if the parameter sb_t_blob_par::blob_contour is set to 1.

Definition at line 9337 of file sb.h.

◆ sb_t_pixel_connection

Defines the pixel connection.

The values are 32 bits both for 32 and 64 bits library version.

Enumerator
SB_PIXEL_CONNECTION_4 

4 connection.

4-connected pixels are neighbors to every pixel that touches one of their edges. These pixels are connected horizontally and vertically. In terms of pixel coordinates, every pixel that has the coordinates (x+1,y), (x-1,y), (x,y+1), (x,y-1) is connected to the pixel at (x,y).

SB_PIXEL_CONNECTION_8 

8 connection. 8-connected pixels are neighbors to every pixel that touches one of their edges or corners. These pixels are connected horizontally, vertically, and diagonally. In addition to 4-connected pixels, each pixel with coordinates (x+1,y), (x+1,y+1), (x,y+1), (x-1,y+1) (x-1,y), (x-1,y-1), (x,y-1), (x+1,y-1) is connected to the pixel at (x,y).

Definition at line 9305 of file sb.h.

Function Documentation

◆ sb_blob_copy()

sb_t_err sb_blob_copy ( sb_t_blob *const  dst,
const sb_t_blob *const  src 
)

Blob copy.

The function creates a copy of the blob src into the blob dst.

Parameters
[out]dstDestination blob.
[in]srcSource blob.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_blob_destroy()

sb_t_err sb_blob_destroy ( sb_t_blob *const  blob)

Destroys the blob.

The function resets the structure.

Parameters
blob[in,out] pointer to the blob
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.*

◆ sb_blob_format_par()

sb_t_err sb_blob_format_par ( int *const  c,
char *const  str,
int  str_size,
int  indentation,
const sb_t_blob_par *const  par 
)

Formats the blob analysis parameters structure.

Interprets the contents of par and converts it to a C-string containing a human-readable version of the corresponding structure.

Parameters
[in,out]cNumber of characters to jump in the string str,
it will be filled with the total number of characters in string str .
The parameter can be NULL.
[out]strPointer to the string.
On successful return, this parameter will be filled with a human-readable version of the blob analysis parameters structure.
[in]str_sizeNumber of bytes of the string str.
[in]indentationNumber of indentation characters.
[in]parPointer to the blob analysis parameters structure.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_blob_init_par()

sb_t_err sb_blob_init_par ( sb_t_blob_par *const  par)

Initializes the fields of the structure.

Parameters
[out]parPointer to the blob analysis parameters structure.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_blob_intersect()

sb_t_err sb_blob_intersect ( const sb_t_blob *const  blob1,
const sb_t_blob *const  blob2,
int  extract_blob_seg,
sb_t_blob **const  res 
)

Blob intersection.

The function extract the blob that represents the intersection of the input blobs.

Parameters
[in]blob1First blob.
[in]blob2Second blob.
[in]extract_blob_segEnables the extraction of the rle.
[out]resPointer to the result blob (null if no intersection is found).
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_blob_plot_roi()

sb_t_err sb_blob_plot_roi ( const sb_t_blob *const  blob,
sb_t_roi *const  roi,
unsigned char  gl 
)

Prints the blob on the roi.

The function print the blob on the provided roi.
The function updates the sb_t_roi::bounding_box parameter of the roi.

Parameters
[in]blobPointer of the blob.
[in]roiPointer to the ROI.
[in]glGray level to be set.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_blobs_clone()

sb_t_err sb_blobs_clone ( sb_t_blobs **const  dst,
const sb_t_blobs *const  src 
)

Blobs structure clone.

The function creates a copy of the blobs src into the blobs dst.

Parameters
[out]dstDestination blobs.
[in]srcSource blobs.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_blobs_create()

sb_t_err sb_blobs_create ( sb_t_blobs **const  blobs)

Creates the blobs structure.

Parameters
[out]blobsPointer to the blob structure. On successful return, this parameter will be updated with the pointer of the blobs structure.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_blobs_destroy()

sb_t_err sb_blobs_destroy ( sb_t_blobs **const  blobs)

Destroys the blobs structure.

Parameters
[in,out]blobspointer to the blobs structure. It is set to NULL.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_blobs_detection

◆ sb_blobs_detection()

sb_t_err sb_blobs_detection ( sb_t_blobs **const  blobs,
const sb_t_image *const  image,
const sb_t_roi *const  roi,
const sb_t_blob_par *const  par,
sb_t_image_circularity_type  circularity_type 
)

Blob analysis.

The function search for the blobs according to the values in the parameters structure.

Parameters
[out]blobsList of the blobs ordered by area descending.
On successful return, this parameter will be updated with the pointer of the blobs structure.
[in]imageImage on which to find the blobs. The format must be SB_IMAGE_FORMAT_BW.
[in]roiROI of the image where to search the blobs. The ROi may be both compress and uncompress. In case it is uncompress the bounding box must be defined.
[in]parPointer to the structure of the blob analysis parameters.
[in]circularity_typeCircularity property of the image
If the image is circular, the function manages the blobs that are divided between the beginning and the end of the image. In this case only one blob is returned which can be either in the initial or final part of the image so that the center of the blob falls within the image, furthermore the coordinates of the contour points and the rle encoding can have negative coordinates or greater than the image width.
Only SB_IMAGE_CIRCULARITY_TYPE_HORIZONTAL is managed.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_blobs_destroy;

◆ sb_blobs_plot_roi()

sb_t_err sb_blobs_plot_roi ( const sb_t_blobs *const  blobs,
sb_t_roi *const  roi,
unsigned char  gl 
)

Prints the blobs on the roi.

The function print the blobs on the provided roi.
The function updates the sb_t_roi::bounding_box parameter of the roi.

Parameters
[in]blobsPointer of the blobs.
[in]roiPointer to the ROI.
[in]glGray level to be set.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.