blob.c File Reference

This file implements several functions we need to process color blobs. More...

#include <string.h>
#include <stdio.h>
#include "blob.h"

Include dependency graph for blob.c:

Go to the source code of this file.

Functions

blob_tcreateNewEmptyBlob (void)
 Creates a new blob.
blob_tcreateNewBlob (int left, int right, int top, int bottom, blob_t *next)
 Creates a new blob with the given values.
int doBlobsIntersect (const blob_t *b1, const blob_t *b2)
 Checks if two blobs intersect.
int mergeTwoBlobs (blob_t *blob1, const blob_t *blob2)
 Merges two blobs together and saves the result in the first one.
void mergeBlobList (blob_t *blobList)
 Takes the list, goes through it and merges all intersecting blobs.
blob_tfindBestBlob (blob_t *blobList)
 Find the "best" blob in our list, whatever "best" means.
void dropBlobList (blob_t *blobList)
 Deletes the blob list an frees the allocated memory.
int goodHsvPixel (shsv_pixel_t *pixel, const shsv_pixel_t *minPixel, const shsv_pixel_t *maxPixel)
 This function checks whether a given pixel is within the specified treshhold.
blob_tmarkHsvPixelNeighborhood (const shsv_frame_t *frame, char *marks, int pos, const shsv_pixel_t *minPixel, const shsv_pixel_t *maxPixel)
 Checks a pixel's neighbourhood and marks it positively when all 8 neighbour pixels are within the given value.
blob_tsearchForBlobs (const shsv_frame_t *frame, const shsv_pixel_t *minPixel, const shsv_pixel_t *maxPixel)
 Searches for blobs in the given frame.
int markBlobs (shsv_frame_t *frame, blob_t *blobList, const shsv_pixel_t *markPixel)
 Marks the given blob list in the given frame by coloring their outline with the given pixel.
void markOneBlob (shsv_frame_t *frame, const blob_t *blob, const shsv_pixel_t *markPixel)
 Marks the given blob in the given frame by coloring their outline with the given pixel.
void printBlobList (FILE *stream, blob_t *blobList)
 Prints the coordinates of every blob in the list to the given stream.


Detailed Description

This file implements several functions we need to process color blobs.

Version:
Id
blob.c,v 1.13 2008/09/18 12:59:01 prokop Exp

Definition in file blob.c.


Function Documentation

blob_t* createNewBlob ( int  left,
int  right,
int  top,
int  bottom,
blob_t next 
)

Creates a new blob with the given values.

Parameters:
left Blob's left border
right Blob's right border
top Blob's top border
bottom Blob's bottom border
next next blob in the list
Returns:
a new blob initialized with the given values

Definition at line 34 of file blob.c.

blob_t* createNewEmptyBlob ( void   ) 

Creates a new blob.

It's values are jibberish (they're uninitialized). You have been warned.

Returns:
a new blob initialized with nonsense values

Definition at line 30 of file blob.c.

int doBlobsIntersect ( const blob_t blob1,
const blob_t blob2 
)

Checks if two blobs intersect.

Blobs won't be changed.

Parameters:
blob1 First blob
blob2 Second blob
Returns:
true if blobs intersect, false else. Caution! Do not take "intersect" literally. First it was implemented as real intersection (i.e. at least one common pixel), now it's true if blobs are in direct neighbourhood. It can be changed to any distance.
-- "Use the source, Luke!..."

Definition at line 45 of file blob.c.

void dropBlobList ( blob_t blobList  ) 

Deletes the blob list an frees the allocated memory.

Parameters:
blobList blob list to delete

Definition at line 122 of file blob.c.

blob_t* findBestBlob ( blob_t blobList  ) 

Find the "best" blob in our list, whatever "best" means.

Right now "best" means: the rectangle (blob) with the largest shortest side - that's a nice criteria for saying: the most quadratic one.

Parameters:
blobList Pointer to the first blob in the blob list
Returns:
the "best" blob in the list

Definition at line 96 of file blob.c.

int goodHsvPixel ( shsv_pixel_t pixel,
const shsv_pixel_t minPixel,
const shsv_pixel_t maxPixel 
) [inline]

This function checks whether a given pixel is within the specified treshhold.

Parameters:
pixel HSV pixel which will be checked
minPixel Pixel holding the minima for our blob
maxPixel Pixel holding the maxima for our blob
Returns:
0 (false) if pixel values are outside the treshhold values, true else. This function is for internal use.

Definition at line 141 of file blob.c.

int markBlobs ( shsv_frame_t frame,
blob_t blobList,
const shsv_pixel_t markPixel 
)

Marks the given blob list in the given frame by coloring their outline with the given pixel.

Parameters:
frame HSV frame holding our picture and in which we will paint the blobs' outline
blobList A list to blobs which we will mark
markPixel The blob's outline will be marked with this pixel
Returns:
number of marked blobs

Definition at line 227 of file blob.c.

blob_t* markHsvPixelNeighborhood ( const shsv_frame_t frame,
char *  marks,
int  pos,
const shsv_pixel_t minPixel,
const shsv_pixel_t maxPixel 
) [inline]

Checks a pixel's neighbourhood and marks it positively when all 8 neighbour pixels are within the given value.

Parameters:
frame HSV frame containing our pixels
marks a byte array which holds our marking map.
pos Pixel's position in the data array, e.g. (x,y) = frameWidth*y+x
minPixel Pixel holding the minima for our blob
maxPixel Pixel holding the maxima for our blob
Returns:
a new blob if all pixels matched the treshholds, NULL else This function is for internal use only.

Definition at line 171 of file blob.c.

void markOneBlob ( shsv_frame_t frame,
const blob_t blob,
const shsv_pixel_t markPixel 
) [inline]

Marks the given blob in the given frame by coloring their outline with the given pixel.

Parameters:
frame HSV frame holding our picture and in which we will paint the blob's outline
blob The blob which we will mark
markPixel The blob's outline will be marked with this pixel

Definition at line 239 of file blob.c.

void mergeBlobList ( blob_t blobList  ) 

Takes the list, goes through it and merges all intersecting blobs.

Parameters:
blobList Pointer to the first blob in the list

Definition at line 70 of file blob.c.

int mergeTwoBlobs ( blob_t blob1,
const blob_t blob2 
)

Merges two blobs together and saves the result in the first one.

Parameters:
blob1 First blob to check and target for the resulting blob.
blob2 Second blob. It won't be changed at all.
Returns:
1 if blobs intersect and therefor have been merged, 0 if they do not intersect in which case they have not been altered

Definition at line 58 of file blob.c.

void printBlobList ( FILE *  stream,
blob_t blobList 
)

Prints the coordinates of every blob in the list to the given stream.

Parameters:
stream stream to which the information will be printed, e.g. stderr
blobList the list which members will be shown

Definition at line 265 of file blob.c.

blob_t* searchForBlobs ( const shsv_frame_t frame,
const shsv_pixel_t minPixel,
const shsv_pixel_t maxPixel 
)

Searches for blobs in the given frame.

Parameters:
frame HSV frame in which we search the blobs
minPixel Pixel holding the minima for our blob
maxPixel Pixel holding the maxima for our blob
Returns:
A blob list or better: a pointer to the first element in the list. Blobs are not merged!

Definition at line 197 of file blob.c.


Generated on Sun Sep 28 21:20:01 2008 for Guard by  doxygen 1.5.6