Blue | Comments |
Red | Generic Terms |
Yelow | Reserved words and Commands |
Brown | Defines |
Link | Link to other functions |
#include "VsipTypes.h"
/****************************************************************************
*
* Function
: VsipGrayscaleMorphologicalOpening
*
* Description :
Computes the Gray Scale morphological opening
*
The kernel (nxn) size must be odd and greater than one
*
The difference between the output (dest) size and
*
input (src) size must be 0 or -(n - 1)
*
* Parameters
: src - input image object
*
kernel - nxn kernel object
*
rsz - row size of the output image
*
csz - column size of the output image
*
* Returns
: output image
*
****************************************************************************/
$generic
$VsipGrayscaleMorphologicalOpening
= 'VsipGrayscaleMorphologicalOpeningByte',
$IOType = 'uint8',
$ErosionFunc = 'VsipGrayscaleMorphologicalErosionByte',
$DilationFunc = 'VsipGrayscaleMorphologicalDilationByte';
$VsipGrayscaleMorphologicalOpening
= 'VsipGrayscaleMorphologicalOpeningInt',
$IOType = 'int32',
$ErosionFunc = 'VsipGrayscaleMorphologicalErosionInt',
$DilationFunc = 'VsipGrayscaleMorphologicalDilationInt';
$VsipGrayscaleMorphologicalOpening
= 'VsipGrayscaleMorphologicalOpeningFloat',
$IOType = 'float',
$ErosionFunc = 'VsipGrayscaleMorphologicalErosionFloat',
$DilationFunc = 'VsipGrayscaleMorphologicalDilationFloat';
$VsipGrayscaleMorphologicalOpening
= 'VsipGrayscaleMorphologicalOpeningDouble',
$IOType = 'double',
$ErosionFunc = 'VsipGrayscaleMorphologicalErosionDouble',
$DilationFunc = 'VsipGrayscaleMorphologicalDilationDouble';
$in
$IOType[:,:] $VsipGrayscaleMorphologicalOpening($IOType
src[:,:],
$IOType kernel[:,:], VsipIndexesType
rsz, VsipIndexesType csz)
{
// ***** recover the
src and kernel sizes *****
VsipIndexesType
rs,
VsipIndexesType cs = extents(src);
VsipIndexesType
rk,
VsipIndexesType ck = extents(kernel);
// ***** test the image,
kernel and dest sizes (see header) *****
assert(((rs >
0) && (cs > 0)),
"ERROR: Image can not have zero dimension. (",rs,"x",cs,")\n");
assert((rk ==
ck),
"ERROR: Kernel must be square matrix. (",rk,"x",ck,").\n");
assert(((rk >
1) && ((rk % 2) != 0)),
"ERROR: N must be odd and greater than 1 (",rk,").\n");
assert((((rsz
== rs) && (csz == cs)) ||
((rsz == rs - (rk - 1)) && (csz == cs - (ck - 1)))),
"ERROR: Invalid destination size (",rsz,",",csz,").\n");
// ***** computes the
opening *****
$IOType result0[:,:]
= $ErosionFunc(src,kernel,rsz,csz);
$IOType result[:,:]
= $DilationFunc(result0,kernel,rsz,csz);
} return (result);
$end_generic