DLBlur Class Reference

Blur an image. More...

#include <DLBlur.h>

List of all members.

Public Member Functions

DLImage dlBinaryHorizontalBlur (const DLImage &in, int thresholdValue, bool reload=false)
DLImage dlBinaryHorizontalBlur (int thresholdValue)

Static Public Member Functions

static DLImage dlBlur (const DLImage &in, int numberOfTimes=1)


Detailed Description

Blur an image.

Definition at line 13 of file DLBlur.h.


Member Function Documentation

static DLImage DLBlur::dlBlur ( const DLImage in,
int  numberOfTimes = 1 
) [static]

Blur an image. This algorithm is implemented as a static function, so no object of class DLBlur needs to be instantiated. See below for a usage example:

 DLImage i ("test.tif");
 DLImage blurredImage = DLBlur::dlBlur(i);

This function (currently) requires a color image as input. At each application of the blur operation, a 5x5 blur filter is convolved with the image:

\[ \left[ \begin{array}{rrrrr} 0 & 0 & 1 & 0 & 0 \\ 0 & 8 & 21 & 8 & 0 \\ 1 & 21 & 59 & 21 & 1 \\ 0 & 8 & 21 & 8 & 0 \\ 0 & 0 & 1 & 0 & 0 \end{array} \right] \]

Parameters:
in DLImage to blur
numberOfTimes number of times to apply blur operation
Returns:
blurred image

DLImage DLBlur::dlBinaryHorizontalBlur ( const DLImage in,
int  thresholdValue,
bool  reload = false 
)

This method provides a mechanism for performing a very fast "blur" of binary images. This is done by creating an alternate representation of the image, refered to as the distance representation. In the distance representation each pixel is represented by how far it is from its neighbors horizontally.

Once the distance representation has been created, a method is provided to threshold based on a user defined parameter. A "blurred" image is returned in which all pixels whose value in the distance representation is less then the threshold are set to black.

The current distance representation is constructed such that the values it contains can range from 0 (for a pixel that is black in the original image) to (the image width - 1).

This method operates on a 1 byte/pixel ("grayscale") representation of a binary image. It is up the the application to assure the input image represents binary data. All non-white pixels in the input image will be treated as if they are black in calculating the distanceRepresentation. An exception is thrown if input image is not grayscale.

A single DLBlur instance may be used to blur multiple images using the reload parameter. In order to preserve the added speed provided by this algorithm, one should do all blurring on one image before reloading with a different image. In the event that multiple blurs need to occur in parallel, it is suggested that another DLBlur object be created. See the below example code:

 DLImage a1("bw_8bit.tif");
 DLImage a2("bw_8bit2.tif");

 DLBlur b;
 b.dlBinaryHorizontalBlur(a1,5);
 b.dlBinaryHorizontalBlur(4);           // note that the image name is
                                        // no longer necessary.
 b.dlBinaryHorizontalBlur(a1,3);        // but can be given nonetheless.

 b.dlBinaryHorizontalBlur(a2,5,true);   // note that it is necessary
                                        // to tell dlBinaryHorizontalBlur
                                        // that you want to reload with
                                        // a new image.
 b.dlBinaryHorizontalBlur(4);           // now blurring a2 with threshold of 4

Parameters:
in DLImage to blur ( bw image in 8-bit colorspace)
thresholdValue int value under which pixels will be set to black
reload flag informing the method that this is a new image to be blurred
Returns:
blurred image
Exceptions:
DLException DL_WRONG_FORMAT_EXCEPTION Only accepts grayscale (8-bit) BW images

DLImage DLBlur::dlBinaryHorizontalBlur ( int  thresholdValue  ) 

See DLImage DLBlur::dlBinaryHorizontalBlur ( const DLImage & in, int thresholdValue, bool reload = false );

Parameters:
thresholdValue int value under which pixels will be set to black
Returns:
blurred image
Exceptions:
DLException DL_NULL_POINTER_EXCEPTION when an image has not been loaded yet.


The documentation for this class was generated from the following file:

DOCLIB is being developed under contract by a collaboration between:
The Laboratory for Language and Media Processing
Unviersity of Maryland, College Park
and
Booz | Allen | Hamilton

All Rights Reserved, 2003-2007