Dali: Vision -- C API

[ Header Files | Constants | Thresholding | Smoothing | Edge Detection | Morphology Operations | Misc. Operations | Slide Matching | See Also ]

Header Files

#include <dvmvision.h>

Constants

Return Code

These represent the possible return values from Dali vision functions. DVM_VISION_OK is returned if all goes well. The error codes are included below.

    #define DVM_VISION_OK 0
    #define DVM_NOT_BYTE_ALLIGNED -1
    #define DVM_NOT_DIFFERENT_SIZES -2
    #define DVM_BAD_HEIGHT -3
    #define DVM_USE_ALLIGN -4
    #define DVM_BAD_BLOCK_SIZE -5
    #define DVM_BAD_THRESHOLD -6
    #define DVM_BAD_NUM_PASSES -7
    #define DVM_BAD_PERCENT -8
    #define DVM_SCRATCH_SIZE_TOO_SMALL -9
    #define DVM_BAD_LOW_VAL -11
  

Miscellaneous

To avoid excessive calls to malloc and free, several vision functions allocate a scratch buffer of this size on the stack. This size works for all the currently implemented algorithms.

    #define SCRATCHSIZE 10000
  

Operators

Thresholding

int BitAdaptiveThreshold8(ByteImage *src, BitImage *dest, int blockw, int blockh, int maxVariance, int allWhite, int lowVal);

int ByteComputeThreshold (ByteImage *srcBuf, int percent);

int BitMakeFromThreshold8 (ByteImage *src, BitImage *dest, int threshold);

int ByteMakeFromThreshold8 (ByteImage *src, ByteImage *dest, int threshold, int lowVal);

int ByteMakefromBit8 (BitImage *src, ByteImage *dest)


Smoothing

int ByteSmooth(ByteImage *srcBuf, ByteImage *destBuf, int numPasses)

int ByteSmoothGaussian (ByteImage *src, ByteImage *dest, double sigma)


Edge Detection

int ByteEdgeDetectSobel (ByteImage *srcBuf, ByteImage *dest1Buf, ByteImage *dest2Buf, int percent, int *thresh1, int *thresh2)

int ByteEdgeDetectCanny(ByteImage *src, int thresh1, int thresh2, ByteImage *dest)


Morphology Operations

int BitDilateHorizontal8 (BitImage *src, BitImage *dest)

int BitDilateVertical8 (BitImage *src, BitImage *dest)

    Same as BitDilateHorizontal8 except the top and bottom neighbors of every pixel in src are set in dest, instead of the left and right neighbors.

int BitDilate8 (BitImage *src, BitImage *dest);

    For every pixel with a value of 1 in BitImage src, set its neighboring pixels to 1, and write the results to BitImage dest. Returns NOT_BYTE_ALLIGNED if both BitImages are not byte alligned. For efficiency, BitDilate8 allocates space on the stack instead of the heap, meaning a constant amount must be allocated. The constant SCRATCHSIZE defines this amount, and may need to be changed for very large bit images.

int BitErode8 (BitImage *src, BitImage *dest)

    The inverse of the dilation operation. Every pixel that is set in src, but is NOT completely surrounded by set pixels, is unset in dest. Returns DVM_NOT_BYTE_ALIGNED if either src or dest are not byte aligned.


Misc. Operations

int BitCountOverlap8 (BitImage *buf1, BitImage *buf2, int *percent)

    Return the quotient of the number of bits in the intersection of buf1 and buf2 by the number of "1" bits in buf1. Returns DVM_NOT_BYTE_ALIGNED if either src or dest are not byte aligned.

int BitCountOverlap (BitImage *buf1, BitImage *buf2, int *percent)

    Same as BitCountOverlap8, except there is no requirement for the images to be byte aligned.

int BitAllWhite (BitImage *buf)

    Tests if buf has no dark pixels.

float BitCompare (BitImage *buf1, BitImage *buf2)

    Returns the ratio of the number of pixels set in the intersection of the two images to the number of pixels set in the union of the two images.

int BitCompareBlocks (BitImage *bit1, BitImage *bit2, int size)

    For a block size of sizeXsize pixels (size is usually 8 or 16 pixels), return the average absolute block difference.

void BitFindCentroid (BitImage *buf, int val, int *xmean, int *ymean)

    Returns the X and Y coordinate of the centroid of the set pixels in buf.

int ByteGradientFull (ByteImage *buf, short *dx, short *dy, int *mag);

    Returns the gradient at every pixel in the X direction in dx, the gradient int the Y direction in dy, and the square of the magnitude of the gradient at each pixel in mag.


Slide Matching

int ByteFindBackgroundIntensity (ByteImage *buf)

    Returns the average pixel value of the background of buf, assumed to be a slide master.

int ByteFindBoundingBox (ByteImage *buf, int px, int py, int *x0, int *y0, int *x1, int *y1, int *x2, int *y2, int *x3, int *y3);

    Given a frame of video with the registration slide in buf, and the centroid location in px and py, this determines the corners of a bounding box in which to search for the real corners of the registration slide.

void ByteFindOuterCorners (ByteImage *buf, int ix0, int iy0, int ix1, int iy1, int ix2, int iy2, int ix3, int iy3, int *x0, int *y0, int *x1, int *y1, int *x2, int *y2, int *x3, int *y3);

    Given the bounding box points as returned by ByteFindBoundingBox, this returns the corners of the registration slide.

int ByteMakeFromBitIntersect ( ByteImage *r, ByteImage *g, ByteImage *b, BitImage *src1, BitImage *src2);

    A visualization tool for BitCountOverlap. Shows the pixels in the intersection of src1 and src2 in black, pixels in src1 not in src2 in red, and those in src2 but not in src1 in green.


See Also

ByteImage , BitImage


Last updated : Saturday, November 14, 1998, 07:50 PM