#include <DLBlur.h>
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) |
Definition at line 13 of file DLBlur.h.
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:
in | DLImage to blur | |
numberOfTimes | number of times to apply blur operation |
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
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 |
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 );
thresholdValue | int value under which pixels will be set to black |
DLException | DL_NULL_POINTER_EXCEPTION when an image has not been loaded yet. |