2.1.12.5.2 ocmath_erode_matrix_with_strel


Description

Erodes grayscale and binary image.

Syntax

int ocmath_erode_matrix_with_strel( int nRows, int nCols, double * pMat, StrelResult * pStrel )

Parameters

nRows
[input] row number of the matrix
nCols
[input] column number of the matrix
pMat
[modify] on input, pointer to the matrix that will be dilated; on output, pointer to the matrix after dilated.
pStrel
[input] pointer to the object of structure StrelResult. StrelResult defines a morphological structuring element.
It has 4 elements:
pNHoodMat: pointer to neighborhood matrix. The neighborhood matrix specifies the neighborhood.
pHeightMat: pointer to height matrix. The height matrix must be real and finite valued and same size as the neighborhood matrix. When it is NULL or all cells of it equals 0, se is flat structuring element, or else nonflat.
nRows: the row number of matrix;
nCols: the column number of matrix;

Return

Returns 0 on success and a non-zero error code on failure.

Examples

EX1

void matrixbase_ImDilate_ex2()
{
    matrix matData = {{0,0,0,0,0},
                      {0,1,2,3,0},
                      {0,2,3,4,0},
                      {0,3,4,5,0},
                      {0,0,0,0,0}};
    //see the definition of StrelParams in ocmath.h
    matrix matHood =  {{0,1,0},{1,2,1},{0,1,0}};
    matrix matHeight;
    matHeight = matHood;
    StrelParams sp;
    sp.nRows = 3;
    sp.nCols = 3;
    sp.pNHood = matHood;
    sp.pHeight = matHeight;
        
    matrix mNHood, mHeight;
    mNHood.SetSize(3,3);
    mHeight.SetSize(3,3);
    StrelResult se;
    se.nRows = 3;
    se.nCols = 3;
    se.pNHoodMat = mNHood;
    se.pHeightMat = mHeight;
    int nRet = ocmath_make_strel(&se, &sp, ARBITRARY_SHAPE);
    if(nRet != OE_NOERROR)
    {
        printf("  Error: Make strel failed. Error Code=%d\n", nRet);
        return;
    }
        
    nRet = ocmath_erode_matrix_with_strel(5, 5, matData, &se);
    if(nRet != OE_NOERROR)
        printf("  Error: ocmath_erode_matrix_with_strel failed. Error Code=%d\n", nRet);
}

Remark

See Also

ocmath_dilate_matrix_with_strel, ocmath_make_strel

Header to Include

origin.h

Reference