Intel® Integrated Performance Primitives Developer Guide and Reference

ID 790148
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

MarkSpeckles

Marks small noise blobs (speckles) in an image.

Syntax

IppStatus ippiMarkSpeckles_<mod>(Ipp<datatype>* pSrcDst, int srcDstStep, IppiSize roiSize, Ipp<datatype> speckleVal, int maxSpeckleSize, Ipp<datatype> maxPixDiff, IppiNorm norm, Ipp8u* pBuffer);

Supported values for mod:

8u_C1IR 16u_C1IR 16s_C1IR 32f_C1IR

Include Files

ippcv.h

Domain Dependencies

Headers: ippcore.h, ippvm.h, ipps.h, ippi.h

Libraries: ippcore.lib, ippvm.lib, ipps.lib, ippi.lib

Parameters

pSrcDst

Pointer to the source and destination image.

srcDstStep

Distance, in bytes, between the starting points of consecutive lines in the source and destination image.

roiSize

Size of the source and destination image ROI in pixels.

speckleVal

Value to set to the speckles.

maxSpeckleSize

Maximum size of the image component to consider it as a speckle.

maxPixDiff

Maximum difference between neighboring disparity pixels to put them into the same component.

norm

Type of the norm to form the mask for marker propagation. Possible value is:

ippiNormL1

L1 norm (4-connectivity)

pBuffer

Pointer to the work buffer.

Description

This function operates with ROI (see Regions of Interest in Intel IPP).

This function marks small noise blobs (speckles) in the source image.

The pSrcDst parameter points to the processed source and destination image ROI.

The function finds small connected components and set them to the speckleVal value. This function marks only components with size that is less than, or equal to maxSpeckleSize. Pixels of the image belong to the same connected component if the difference between adjacent pixels (considering 4-connected adjacency) is less than, or equal to the maxSpeckleSize value.

NOTE:

This release does not support 8-connectivity.

The function does not process the pixels of the image that already have the speckleVal value.

Before using the ippiMarkSpeckles function, compute the size of the external buffer using the MarkSpecklesGetBufferSize function.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when pSrcDst or pBufferSize is NULL.

ippStsSizeErr

Indicates an error when roiSize has a field with a zero or negative value.

ippStsNotEvenStepErr

Indicates an error when one of the step values is not divisible by 4 for floating-point images, or by 2 for short-integer images.

ippStsNormErr

Indicates an error when norm has an incorrect or not supported value.

Example

/*******************************************************************************
* Copyright 2015 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/

// A simple example of performing filtering of small noise blobs (speckles)
// in the image using Intel(R) Integrated Primitives (Intel(R) IPP) functions:
//     ippiMarkSpecklesGetBufferSize
//     ippiMarkSpeckles_8u_C1IR


#include <stdio.h>
#include "ipp.h"

#define WIDTH  128  /* image width  */
#define HEIGHT  64  /* image height */

/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN exitLine:                                  /* Label for Exit */
#define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */

/* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status  */

int main(void)
{
    IppStatus status = ippStsNoErr;
    int numChannels = 1;
    Ipp8u* pSrcDst = NULL;                /* Pointers to source/destination images */
    int srcDstStep = 0;                   /* Steps, in bytes, through the source/destination images */
    IppiSize roiSize = { WIDTH, HEIGHT }; /* Size of source/destination ROI in pixels */
    Ipp8u  speckleVal = 255;              /* Disparity value */
    Ipp8u  maxPixDif = 1;                 /* Maximum difference between neighbor pixels */
    Ipp32s maxSpeckleSize = 8;            /* Maximum difference between neighbor pixels */
    Ipp8u* pBuffer = NULL;                /* Pointer to the work buffer */
    int bufferSize = 0;

    /* Computes the temporary work buffer size */
    check_sts( status = ippiMarkSpecklesGetBufferSize(roiSize, ipp8u, numChannels, &bufferSize) )

    pBuffer = ippsMalloc_8u(bufferSize);
    pSrcDst = ippiMalloc_8u_C1(roiSize.width, roiSize.height, &srcDstStep);

    check_sts( status = ippiMarkSpeckles_8u_C1IR(pSrcDst, srcDstStep, roiSize, speckleVal, maxSpeckleSize, maxPixDif, ippiNormL1, pBuffer) )

EXIT_MAIN
    ippiFree(pSrcDst);
    ippsFree(pBuffer);
    printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
    return (int)status;
}

See Also