diewald_CV_kit.blobdetection
Class BlobDetector

java.lang.Object
  extended by diewald_CV_kit.blobdetection.BlobDetector

public final class BlobDetector
extends Object

BlobDetector is the main entry class of the library.

it computates the blobs/regions/labels, and their contours found in an image/video/etc., based on the condition-interface (BLOBable).

Author:
thomas diewald (c) 2011

Constructor Summary
BlobDetector(int width, int height)
          define dimensions of the blob-detection.
 
Method Summary
 void computeBlobPixels(boolean compute_blob_pixels)
          if computeBlobPixels(true) is called, the library generates a new pixelarray for each detected blob, after each update.
 void computeContours(boolean compute_contours)
          defines, whether the the contours (outer and inner ones) of each blob are generated.
 ArrayList<Blob> getBlobs()
          getBlobs() returns the detected blobs after each update().
 BoundingBox getDetectingArea()
          returns the boundingsbox, which defines the detection-area (by reference).
 Pixel[][] getPixels()
          getPixels() returns an 2-d array of pixels.
 void setBLOBable(BLOBable blobable)
          set the condition (BLOBable) that defines, which pixels are part of a blob.
 void setDetectingArea(BoundingBox bb)
          set a bounding-box to define the detection-area (by reference).
 void setMinMaxPixels(int min_blob_pixels, int max_blob_pixels)
          define the minimum/maximum number of pixels a blob can have.
 void setResolution(int pixel_jump)
          defines, how many pixels are skipped on each detection.
 boolean update()
          generate blobs/contours/etc. depending on the previous settings.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlobDetector

public BlobDetector(int width,
                    int height)
define dimensions of the blob-detection.

Parameters:
width - width of the frame
height - height of the frame
Method Detail

update

public final boolean update()
generate blobs/contours/etc. depending on the previous settings.

Returns:
true on success, false on any kind of failure.

setDetectingArea

public final void setDetectingArea(BoundingBox bb)
set a bounding-box to define the detection-area (by reference).
note: the bounds are not checked, so make sure, they are within the image-bounds.

Parameters:
bb - bounding-box.

getDetectingArea

public final BoundingBox getDetectingArea()
returns the boundingsbox, which defines the detection-area (by reference).

Returns:
the boundingsbox, which defines the detection-area.

setBLOBable

public final void setBLOBable(BLOBable blobable)
set the condition (BLOBable) that defines, which pixels are part of a blob. this condition gets called for every pixels.

Parameters:
blobable - the condition

setResolution

public final void setResolution(int pixel_jump)
defines, how many pixels are skipped on each detection.
this can be important on a low frame-rate, or if the resolution of the generated blob is not that important. e.g.
setResolution(1) - take every pixel for detection setResolution(2) - take every second pixel for detection setResolution(3) - take every third pixel for detection

Parameters:
pixel_jump -

setMinMaxPixels

public final void setMinMaxPixels(int min_blob_pixels,
                                  int max_blob_pixels)
define the minimum/maximum number of pixels a blob can have.
only blobs with a number of pixels within this range, are detected.

Parameters:
min_blob_pixels - minimum number of pixels
max_blob_pixels - maximum number of pixels

computeContours

public final void computeContours(boolean compute_contours)
defines, whether the the contours (outer and inner ones) of each blob are generated.
if you dont need contours, call computeContours(false);
the default setting is: computeContours(true);

Parameters:
compute_contours -

computeBlobPixels

public final void computeBlobPixels(boolean compute_blob_pixels)
if computeBlobPixels(true) is called, the library generates a new pixelarray for each detected blob, after each update.
if you don't need this blobs pixel-array, you can save a lot of computation-time, by calling computeBlobPixels(false), which is the default setting!

Parameters:
compute_blob_pixels -

getBlobs

public final ArrayList<Blob> getBlobs()
getBlobs() returns the detected blobs after each update().

Returns:
the detected blobs

getPixels

public final Pixel[][] getPixels()
getPixels() returns an 2-d array of pixels.
each pixel contains information about its position x/y, and the blobs id, it belongs to (call: "pixel".getBlob() ).
this array is used internally, to label the pixels accordingly to their neighborhood, defined by the interface BLOBable.
on each blob-detection update, each pixel in this array gets a reset.

Returns:
the labeled pixels


Processing library diewald_CV_kit by Thomas Diewald. (C) 2012