AuxPerimeter



 
 

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

 

#include "VsipTypes.h"

/****************************************************************************
 *
 *  Auxiliary Function    : AuxPerimeter
 *
 *  Description : Pads the image with a constant value
 *
 *  Parameters  : image : image to pad
 *                top   : top increment
 *                bottom: bottom increment
 *                left  : left increment
 *                right : right increment
 *                const : Value to use in the border
 *
 *  Return      : padded image
 *
 ****************************************************************************/
$generic

  $AuxPerimeter = 'AuxPerimeterBit',    $IOType = 'uint1';
  $AuxPerimeter = 'AuxPerimeterByte',   $IOType = 'uint8';
  $AuxPerimeter = 'AuxPerimeterInt',    $IOType = 'int32';
  $AuxPerimeter = 'AuxPerimeterFloat',  $IOType = 'float';
  $AuxPerimeter = 'AuxPerimeterDouble', $IOType = 'double';

$in

$IOType[:,:] $AuxPerimeter($IOType image[:,:], VsipIndexesType top,
            VsipIndexesType bottom, VsipIndexesType left,
            VsipIndexesType right, $IOType const)
{

  // ***** recover the image size *****
  VsipIndexesType rs, VsipIndexesType cs = extents(image);

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

  // ***** computes the borders *****
  VsipIndexesType vert = rs+top+bottom;
  VsipIndexesType horz = cs+left+right;
  VsipIndexesType vertlim = rs+top;
  VsipIndexesType horzlim = cs+left;

  // ***** creates the perimeter around the image *****
  $IOType result[:,:] =
       forVsipIndexesType i, VsipIndexesType j in [vert,horz]
            { $IOType elem =
               if ((i < top) || (i >= vertlim) || (j < left) || (j >= horzlim))
                    return(const)
               else
                    return(image[i-top,j-left]);
            }
        return(array(elem));
 

} return (result);

$end_generic

/****************************************************************************
 *
 *  Auxiliary Function    : AuxPerimeterCx
 *
 *  Description : Pads the image with a constant value
 *
 *  Parameters  : image : image to pad
 *                top   : top increment
 *                bottom: bottom increment
 *                left  : left increment
 *                right : right increment
 *                const : Value to use in the border
 *
 *  Return      : padded image
 *
 ****************************************************************************/
$generic

  $AuxPerimeterCx = 'AuxPerimeterCxInt',  $IOType = 'complex int32';
  $AuxPerimeterCx = 'AuxPerimeterCxFloat',$IOType = 'complex float';

$in

$IOType[:,:] $AuxPerimeterCx($IOType image[:,:], VsipIndexesType top,
             VsipIndexesType bottom, VsipIndexesType left,
             VsipIndexesType right, $IOType const)
{

  // ***** recover the image size *****
  VsipIndexesType rs, VsipIndexesType cs = extents(image);

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

  // ***** computes the borders *****
  VsipIndexesType vert = rs+top+bottom;
  VsipIndexesType horz = cs+left+right;
  VsipIndexesType vertlim = rs+top;
  VsipIndexesType horzlim = cs+left;

  // ***** creates the perimeter around the image *****
  $IOType result[:,:] =
       forVsipIndexesType i, VsipIndexesType j in [vert,horz]
            { $IOType elem =
                if ((i < top) || (i >= vertlim) || (j < left) || (j >= horzlim))
                     return(const)
                else
                     return(image[i-top,j-left]);
            }
        return(array(elem));
 

} return (result);

$end_generic