Look up Table



 
 
 

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

 

#include "VsipTypes.h"

/****************************************************************************
 *
 *  Function    : VsipLookUpTable
 *
 *  Description : Translate the image using a look up table
 *
 *  Parameters  : src - input image object
 *                table - translation tablen
 *
 *  Returns     : output image
 *
 ****************************************************************************/
$generic

   $VsipLookUpTable = 'VsipLookUpTableByte', $IOType = 'uint8';
   $VsipLookUpTable = 'VsipLookUpTableInt',  $IOType = 'int32';

$in

$IOType [:,:] $VsipLookUpTable($IOType src[:,:], $IOType table[:])
{

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

  // ***** test the sizes of the arrays  *****
  assert(((rs > 0) && (cs > 0)),
         "ERROR: Image can not have zero dimention. (",rs,"x",cs,")\n");
  assert((length > 0),
         "ERROR: Table can not have zero dimention.\n");
  assert((length >= array_max(src)),
         "ERROR: Table incompatible with image.\n");

  // ***** Uses a look up table to find the new value of a pixel *****
  $IOType result[:,:] =
      for elem in src
      return(array(table[elem]));

} return (result);

$end_generic