Visible to Intel only — GUID: GUID-F7E1EBAD-1A89-4FFC-AE3C-0804F8A88753
Visible to Intel only — GUID: GUID-F7E1EBAD-1A89-4FFC-AE3C-0804F8A88753
SAD
Computes sums of absolute differences (SAD) for a template image and different locations within a source image where the template image can fit.
Syntax
IppStatus ippiSAD_<mod>(const Ipp<srcDatatype>* pSrc, int srcStep, IppiSize srcRoiSize, const Ipp<srcDatatype>* pTpl, int tplStep, IppiSize tplRoiSize, Ipp<dstDatatype>* pDst, int dstStep, IppiROIShape shape, int scaleFactor, Ipp8u* pBuffer);
IppStatus ippiSAD_32f_C1R(const Ipp<srcDatatype>* pSrc, int srcStep, IppiSize srcRoiSize, const Ipp<srcDatatype>* pTpl, int tplStep, IppiSize tplRoiSize, Ipp<dstDatatype>* pDst, int dstStep, IppiROIShape shape, Ipp8u* pBuffer);
Supported values for mod:
8u32s_C1RSfs |
16u32s_C1RSfs |
16s32s_C1RSfs |
Include Files
ippi.h
Domain Dependencies
Headers: ippcore.h, ippvm.h, ipps.h
Libraries: ippcore.lib, ippvm.lib, ipps.lib
Parameters
pSrc |
Pointer to the source image ROI. |
srcStep |
Distance, in bytes, between the starts of consecutive lines in the source image. |
srcRoiSize |
Size of the source ROI in pixels. |
pTpl |
Pointer to the template image ROI. |
tplStep |
Distance, in bytes, between the starts of consecutive lines in the template image. |
tplRoiSize |
Size of the template ROI in pixels. |
pDst |
Pointer to the destination image ROI. |
dstStep |
Distance, in bytes, between the starts of consecutive lines in the destination image. |
shape |
Enumeration that defines the shape of the result of the SAD operation (see Structures and Enumerators). |
scaleFactor |
Scale factor (see Integer Result Scaling). |
pBuffer |
Pointer to the buffer for internal calculations. |
Description
The ippiSAD function operates with ROI (see Regions of Interest in Intel IPP).
The function only supports the ippiROIValid value of shape, and so the sizes of the destination ROI are different from the sizes of both the source ROI and template ROI and depend on those sizes as follows:
dstRoiSize.width = W =srcRoiSize.width - tplRoiSize.width + 1
dstRoiSize.height = H = srcRoiSize.height - tplRoiSize.height + 1
So there are exactly W*H unique locations within the source image where the template image can fit. The top-left pixel determines each of these locations. For each location, the function computes absolute differences between corresponding pixel values of the source and template images, sums these differences to make the SAD value of the top-left pixel, and assigns the SAD value to the appropriate pixel in the destination buffer.
For integer flavors, the resulting values are also scaled by scaleFactor.
Return Values
ippStsNoErr |
Indicates no error. Any other value indicates an error or a warning. |
ippStsNullPtrErr |
Indicates an error condition if the pSrc, pTpl, pDst, or pBuffer pointer is NULL. |
ippStsSizeErr |
Indicates an error condition if srcRoiSize or tplRoiSize has a field with a zero or negative value or if srcRoiSize in any direction is less than tplRoiSize. |
ippStsStepErr |
Indicates an error condition if srcStep, tplStep, or dstStep has a zero or negative value or is not a multiple of the image data size (4 for floating-point images or 2 for short-integer images) |
ippStsBadArgErr |
Indicates an error condition if scaleFactor <0. |
ippStsNotSupportedModeErr |
Indicates an error condition if intersection of the source and destination ROI is detected or if shape differs from ippiROIValid. |
Example
The code example below shows how to use the ippiSAD_8u32s_C1RSfs function.
Ipp8u src[8*8] = {1, 2, 3, 4, 8, 8, 8, 8, 1, 2, 3, 4, 8, 8, 8, 8, 1, 2, 3, 4, 8, 8, 8, 8, 1, 2, 3, 4, 8, 8, 8, 8, 1, 2, 3, 4, 8, 8, 8, 8, 1, 2, 3, 4, 8, 8, 8, 8, 1, 2, 3, 4, 8, 8, 8, 8, 1, 2, 3, 4, 8, 8, 8, 8}; IppiSize srcRoi = { 7, 7 }; Ipp8u template[3*3] = { 10, 10, 10, 10, 10, 10, 10, 10, 10}; IppiSize tplRoi = { 3, 3 }; Ipp32s dst[8*8] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; IppiSize srcRoi = { 3, 3 }; ippiSADGetBufferSize( srcRoi, tplRoi, ippiROIVaid , 1, &bufferSize); Ipp8u* pBuffer = new Ipp8u [bufferSize]; ippiSAD_8u32s_C1RSfs(src, 8, srcRoi, template, 3, tplRoi, dst, 8, ippiROIVaid , 1, pBuffer); Result: 1 2 3 4 8 8 8 8 10 10 10 36 32 22 15 9 0 0 0 1 2 3 4 8 8 8 8 src 10 10 10 tpl 36 32 22 15 9 0 0 0 dst 1 2 3 4 8 8 8 8 10 10 10 36 32 22 15 9 0 0 0 1 2 3 4 8 8 8 8 36 32 22 15 9 0 0 0 1 2 3 4 8 8 8 8 36 32 22 15 9 0 0 0 1 2 3 4 8 8 8 8 0 0 0 0 0 0 0 0 1 2 3 4 8 8 8 8 0 0 0 0 0 0 0 0 1 2 3 4 8 8 8 8 0 0 0 0 0 0 0 0