Pad with Constant



 
 

Color Convention
 Blue  Comments 
 Red  Generic Terms
 Yelow  Reserved  words and Commands 
 Brown  Defines
  Link  Link to other functions

 

#include "VsipTypes.h"

/****************************************************************************
 *
 *  Function    : VsipPadImageWithConstant
 *
 *  Description : Pads the image with a constant value
 *                           Kernel sizes determines the size of the border
 *
 *  Parameters  : src - input image object
 *                kernel - kernel object
 *                rsz - row size of the output image
 *                csz - column size of the output image
 *
 *  Returns     : padded image
 *
 ****************************************************************************/
$generic

  $VsipPadImageWithConstant = 'VsipPadImageWithConstantBit',    $IOType = 'uint1',
      $Pad = 'AuxPerimeterBit';
  $VsipPadImageWithConstant = 'VsipPadImageWithConstantByte',   $IOType = 'uint8',
      $Pad = 'AuxPerimeterByte';
  $VsipPadImageWithConstant = 'VsipPadImageWithConstantInt',    $IOType = 'int32',
      $Pad = 'AuxPerimeterInt';
  $VsipPadImageWithConstant = 'VsipPadImageWithConstantFloat',  $IOType = 'float',
      $Pad = 'AuxPerimeterFloat';

$in

$IOType[:,:] $VsipPadImageWithConstant($IOType src[:,:], $IOType kernel[:,:],
                               $IOType const, VsipIndexesType rsz,
                              VsipIndexesType csz)
{

  // ***** recover the src and kernel sizes *****
  VsipIndexesType rs, VsipIndexesType cs = extents(src);
  VsipIndexesType rk, VsipIndexesType ck = extents(kernel);

  // ***** test the sizes of the arrays  *****
  assert(((rs > 0) && (cs > 0)),
         "ERROR: Image can not have zero dimention. (",rs,"x",cs,")\n");
  assert(((rk > 0) && (ck > 0)),
         "ERROR: Kernel can not have zero dimention. (",rk,"x",ck,")\n");

  // ***** computes the borders *****
  VsipIndexesType top = rk / 2;
  VsipIndexesType bottom = (rk - 1) / 2;
  VsipIndexesType left = ck / 2;
  VsipIndexesType right = (ck - 1) / 2;

  // ***** test the sizes of the kernel and dest (see header)  *****
  assert(((rsz == rs + top + bottom) && (csz == cs + left + right)),
         "ERROR: Invalid destination size (",rsz,",",csz,").\n");
 

  // ***** creates the  perimeter around src *****
  $IOType result[:,:] = $Pad(src, top, bottom, left, right, const);

} return (result);

$end_generic
 
 

/****************************************************************************
 *
 *  Function    : VsipPadImageWithConstantCx
 *
 *  Description : Pads the image with a constant value
 *                Kernel sizes determines the size of the border
 *
 *  Parameters  : src - input image object
 *                kernel - kernel object
 *                rsz - row size of the output image
 *                csz - column size of the output image
 *
 *  Returns     : paddedimage
 *
 ****************************************************************************/
$generic

  $VsipPadImageWithConstantCx = 'VsipPadImageWithConstantCxInt',
      $IOType = 'complex int32', $Pad = 'AuxPerimeterCxInt';
  $VsipPadImageWithConstantCx = 'VsipPadImageWithConstantCxFloat',
      $IOType = 'complex float', $Pad = 'AuxPerimeterCxFloat';

$in

$IOType[:,:] $VsipPadImageWithConstantCx($IOType src[:,:], $IOType kernel[:,:],
                               $IOType const, VsipIndexesType rsz,
                              VsipIndexesType csz)
{

  // ***** recover the src and kernel sizes *****
  VsipIndexesType rs, VsipIndexesType cs = extents(src);
  VsipIndexesType rk, VsipIndexesType ck = extents(kernel);

  // ***** test the sizes of the arrays  *****
  assert(((rs > 0) && (cs > 0)),
         "ERROR: Image can not have zero dimention. (",rs,"x",cs,")\n");
  assert(((rk > 0) && (ck > 0)),
         "ERROR: Kernel can not have zero dimention. (",rk,"x",ck,")\n");

  // ***** computes the borders *****
  VsipIndexesType top = rk / 2;
  VsipIndexesType bottom = (rk - 1) / 2;
  VsipIndexesType left = ck / 2;
  VsipIndexesType right = (ck - 1) / 2;

  // ***** test the sizes of the kernel and dest (see header)  *****
  assert(((rsz == rs + top + bottom) && (csz == cs + left + right)),
         "ERROR: Invalid destination size (",rsz,",",csz,").\n");
 

  // ***** creates the  perimeter around src *****
  $IOType result[:,:] = $Pad(src, top, bottom, left, right, const);

} return (result);

$end_generic