⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resampc.i

📁 PDTDFB toolbox The filter bank is described in: The Shiftable Complex Directional Pyramid—Pa
💻 I
📖 第 1 页 / 共 4 页
字号:













/* defined(V5_COMPAT) */





/* defined(V5_COMPAT) */



/*
mxAssert(int expression, char *error_message)
---------------------------------------------

  Similar to ANSI C's assert() macro, the mxAssert macro checks the
  value of an assertion, continuing execution only if the assertion
  holds.  If 'expression' evaluates to be true, then the mxAssert does
  nothing.  If, however, 'expression' is false, then mxAssert prints an
  error message to the MATLAB Command Window, consisting of the failed
  assertion's expression, the file name and line number where the failed
  assertion occurred, and the string 'error_message'.  'error_message'
  allows the user to specify a more understandable description of why
  the assertion failed.  (Use an empty string if no extra description
  should follow the failed assertion message.)  After a failed
  assertion, control returns to the MATLAB command line. 

  mxAssertS, (the S for Simple), takes the same inputs as mxAssert.  It 
  does not print the text of the failed assertion, only the file and 
  line where the assertion failed, and the explanatory error_message.

  Note that script MEX will turn off these assertions when building
  optimized MEX-functions, so they should be used for debugging 
  purposes only.
*/













/* $Revision: 1.14.4.1 $ */
/* Prototype _d versions of API functions *//* MATLAB_MEX_FILE */

/* matrix_h */



# 60 "C:\MATLAB71\extern\include\mex.h"
typedef struct mexGlobalTableEntry_Tag
{
    const char *name;             /* The name of the global */
    mxArray    **variable;        /* A pointer to the variable */
} mexGlobalTableEntry, *mexGlobalTable;







# 73 "C:\MATLAB71\extern\include\mex.h"
typedef struct mexFunctionTableEntry_tag {
  const char *  name;
  mxFunctionPtr f;
  int           nargin;
  int           nargout;
  struct _mexLocalFunctionTable *local_function_table;
} mexFunctionTableEntry, *mexFunctionTable;

typedef struct _mexLocalFunctionTable {
  size_t           length;
  mexFunctionTable entries;
} _mexLocalFunctionTable, *mexLocalFunctionTable;

typedef struct {
  void (*initialize)(void);
  void (*terminate)(void);
} _mexInitTermTableEntry, *mexInitTermTableEntry;




# 93 "C:\MATLAB71\extern\include\mex.h"
typedef struct {
  int                   version;
  int                   file_function_table_length;
  mexFunctionTable      file_function_table;
  int                   global_variable_table_length;
  mexGlobalTable        global_variable_table;
  int                   npaths;
  const char **         paths;
  int                   init_term_table_length;
  mexInitTermTableEntry init_term_table;
} _mex_information, *mex_information;

typedef mex_information(*fn_mex_file)(void);

typedef void (*fn_clean_up_after_error)(void);
typedef const char *(*fn_simple_function_to_string)(mxFunctionPtr f);

typedef void (*fn_mex_enter_mex_library)(mex_information x);
typedef fn_mex_enter_mex_library fn_mex_exit_mex_library;

typedef mexLocalFunctionTable (*fn_mex_get_local_function_table)(void);
typedef mexLocalFunctionTable (*fn_mex_set_local_function_table)(mexLocalFunctionTable);




/*
 * This header file "mex.h" declares all the types, macros and
 * functions necessary to interface mex files with the current
 * version of MATLAB.  See the release notes for information on 
 * supporting syntax from earlier versions.
 */







/*
 * mexFunction is the user defined C routine which is called upon invocation
 * of a mex function.
 */

# 138 "C:\MATLAB71\extern\include\mex.h"
void mexFunction(
    int           nlhs,           /* number of expected outputs */
    mxArray       *plhs[],        /* array of pointers to output arguments */
    int           nrhs,           /* number of inputs */
    const mxArray *prhs[]         /* array of pointers to input arguments */
);



/*
 * Issue error message and return to MATLAB prompt
 */

# 154 "C:\MATLAB71\extern\include\mex.h"
extern void mexErrMsgTxt(
    const char	*error_msg	/* string with error message */
    );



/*
 * Issue formatted error message with corresponding error identifier and return to MATLAB
 * prompt.
 */

# 168 "C:\MATLAB71\extern\include\mex.h"
extern void mexErrMsgIdAndTxt(
    const char * identifier, /* string with error message identifier */
    const char * err_msg,    /* string with error message printf-style format */
    ...                      /* any additional arguments */
    );



/*
 * Invoke an unidentified warning. Such warnings can only be affected by the M-code
 * 'warning * all', since they have no specific identifier. See also mexWarnMsgIdAndTxt.
 */

# 184 "C:\MATLAB71\extern\include\mex.h"
extern void mexWarnMsgTxt(
    const char	*warn_msg	/* string with warning message */
    );



/*
 * Invoke a warning with message identifier 'identifier' and message derived from 'fmt' and
 * subsequent arguments. The warning may either get printed as is (if it is set to 'on'), or
 * not actually get printed (if set to 'off'). See 'help warning' in MATLAB for more
 * details.
 */

# 200 "C:\MATLAB71\extern\include\mex.h"
extern void mexWarnMsgIdAndTxt(
    const char * identifier,    /* string with warning message identifer */
    const char * warn_msg,	/* string with warning message printf-style format */
    ...                         /* any additional arguments */
    );



/*
 * mex equivalent to MATLAB's "disp" function
 */

# 215 "C:\MATLAB71\extern\include\mex.h"
extern int mexPrintf(
    const char	*fmt,	/* printf style format */
    ...				/* any additional arguments */
    );






/*
 * Remove all components of an array plus the array header itself
 * from MATLAB's memory allocation list.  The array will now
 * persist between calls to the mex function.  To destroy this
 * array, you will need to explicitly call mxDestroyArray().
 */

# 235 "C:\MATLAB71\extern\include\mex.h"
extern void mexMakeArrayPersistent(
    mxArray *pa              /* pointer to array */
    );



/*
 * Remove memory previously allocated via mxCalloc from MATLAB's
 * memory allocation list.  To free this memory, you will need to
 * explicitly call mxFree().
 */

# 250 "C:\MATLAB71\extern\include\mex.h"
extern void mexMakeMemoryPersistent(void *ptr);



/*
 * Look up a function and return an opaque handle for use with
 * mexCallMATLABFunction.
 */

# 262 "C:\MATLAB71\extern\include\mex.h"
extern void mexGetFunctionHandle(void);



/*
 * Call a function whose handle was determined by mexGetFunctionHandle.
 */

# 273 "C:\MATLAB71\extern\include\mex.h"
extern void mexCallMATLABFunction(void);



/*
 * Register a function pointer as a MATLAB-callable function.
 */

# 284 "C:\MATLAB71\extern\include\mex.h"
extern void mexRegisterFunction(void);



/*
 * mex equivalent to MATLAB's "set" function
 */

# 295 "C:\MATLAB71\extern\include\mex.h"
extern int mexSet(double handle, const char *property, mxArray *value);



/* API interface which mimics the "get" function */

# 304 "C:\MATLAB71\extern\include\mex.h"
extern const mxArray *mexGet(double handle, const char *property);



/*
 * call MATLAB function
 */

# 315 "C:\MATLAB71\extern\include\mex.h"
extern int mexCallMATLAB(
    int		nlhs,			/* number of expected outputs */
    mxArray	*plhs[],		/* pointer array to outputs */
    int		nrhs,			/* number of inputs */
    mxArray	*prhs[],		/* pointer array to inputs */
    const char	*fcn_name		/* name of function to execute */
    );



/*
 * set or clear mexCallMATLAB trap flag (if set then an error in  
 * mexCallMATLAB is caught and mexCallMATLAB will return a status value, 
 * if not set an error will cause control to revert to MATLAB)
 */

# 334 "C:\MATLAB71\extern\include\mex.h"
extern void mexSetTrapFlag(int flag);



/*
 * Perform in-place subscript assignment.
 */

# 345 "C:\MATLAB71\extern\include\mex.h"
extern void mexSubsAssign(
      mxArray *plhs, /* pointer to lhs, to be modified in-place */
      const mxArray *prhs, /* pointer to rhs */
      const mxArray *subs[], /* array of subscripts for lhs */
      int nsubs     /* number os subscripts */
      );



/*
 * Retrieve a specified subset of an array.
 */

# 361 "C:\MATLAB71\extern\include\mex.h"
extern mxArray *mexSubsReference(
      const mxArray *prhs, /* pointer to rhs */
      const mxArray *subs[], /* array of subscripts for rhs */
      int nsubs /* number of subscripts */
      );



/*
 * Print an assertion-style error message and return control to the
 * MATLAB command line.
 */

# 377 "C:\MATLAB71\extern\include\mex.h"
extern void mexPrintAssertion(
		const char *test,
		const char *fname,
		int linenum,
		const char *message);



/*
 * Tell whether or not a mxArray is in MATLAB's global workspace.
 */

# 392 "C:\MATLAB71\extern\include\mex.h"
extern bool mexIsGlobal(const mxArray *pA);



















/*
 * mexAddFlops is no longer allowed.  
 */






/* defined(V5_COMPAT) */


/*
 * Place a copy of the array value into the specified workspace with the
 * specified name
 */

# 436 "C:\MATLAB71\extern\include\mex.h"
extern int mexPutVariable(
    const char *workspace,
    const char *name,
    const mxArray *parray		/* matrix to copy */
    );



/*
 * return a pointer to the array value with the specified variable
 * name in the specified workspace
 */

# 452 "C:\MATLAB71\extern\include\mex.h"
extern const mxArray *mexGetVariablePtr(
    const char *workspace,
    const char *name		/* name of symbol */
    );



/*
 * return a copy of the array value with the specified variable
 * name in the specified workspace
 */

# 467 "C:\MATLAB71\extern\include\mex.h"
extern mxArray *mexGetVariable(
    const char	*workspace,
    const char  *name                /* name of variable in question */
    );



/*
 * Lock a MEX-function so that it cannot be cleared from memory.
 */

# 481 "C:\MATLAB71\extern\include\mex.h"
extern void mexLock(void);



/*
 * Unlock a locked MEX-function so that it can be cleared from memory.
 */

# 492 "C:\MATLAB71\extern\include\mex.h"
extern void mexUnlock(void);



/*
 * Return true if the MEX-function is currently locked, false otherwise.
 */

# 503 "C:\MATLAB71\extern\include\mex.h"
extern bool mexIsLocked(void);



/*
 * Return the name of a the MEXfunction currently executing.
 */

# 514 "C:\MATLAB71\extern\include\mex.h"
extern const char *mexFunctionName(void);



/*
 * Parse and execute MATLAB syntax in string.  Returns zero if successful,
 * and a non zero value if an error occurs.
 */

# 526 "C:\MATLAB71\extern\include\mex.h"
extern int mexEvalString(
   const char *str	   /* matlab command string */
);



/*
 * Register Mex-file's At-Exit function (accessed via MEX callback)
 */

# 539 "C:\MATLAB71\extern\include\mex.h"
extern int mexAtExit(
    void	(*exit_fcn)(void)
    );






/* Copyright 1996-1999 The MathWorks, Inc. */

/* $Revision: 1.9.4.1 $ */
/* Prototype _d versions of API functions */

/* mex_h */


/*
  function y = resampc(x, type, shift, extmod)
  % RESAMPC	Resampling along the column
  %
  %	y = resampc(x, type, shift, extmod)
  %
  % Input:
  %	x:	image that is extendable along the column direction
  %	type:	either 1 or 2 (1 for shuffering down and 2 for up)
  %	shift:	amount of shifts (typically 1)
  %     extmod: extension mode:
  %		'per' 	periodic
  %		'ref1'	reflect about the edge pixels
  %		'ref2'	reflect, doubling the edge pixels 
  %
  % Output:
  %	y:	resampled image with:
  %		R1 = [1, shift; 0, 1] or R2 = [1, -shift; 0, 1]
*/

# 27 "resampc.c"
void
mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    double *x, *px;		/* input matrix and pointer */
    double *y, *py;		/* result matrix and pointer */
    int type;			/* type of resampling */
    int s;			/* amount of shifts */
    char extmod[10];		/* extension mode */

    int i, j, k, m, n;

    /* Parse input */
    if (nrhs < 4)
	mexErrMsgTxt("Not enough input for RESAMPC!");

    x = mxGetPr(prhs[0]);
    m = mxGetM(prhs[0]);
    n = mxGetN(prhs[0]);

    type = (int) mxGetPr(prhs[1])[0];
    if ((type != 1) && (type != 2))
	mexErrMsgTxt("The second input (type) must be either 1 or 2");

    s = (int) mxGetPr(prhs[2])[0];

    if (!mxIsChar(prhs[3]))
	mexErrMsgTxt("EXTMOD arg must be a string");

    mxGetString(prhs[3], extmod, 10);

    /* Create output */
    plhs[0] = mxCreateDoubleMatrix(m, n, mxREAL);
    y = mxGetPr(plhs[0]);

    px = x;
    py = y;

    if (strcmp(extmod, "per") == 0)
    {
	/* Resampling column-wise:
	 * 		y[i, j] = x[<i+sj>, j] 	if type == 1
	 * 		y[i, j] = x[<i-sj>, j] 	if type == 2
	 */


# 71 "resampc.c"
	for (j = 0; j < n; j++)
	{
	    /* Circular shift in each column */
	    if (type == 1)
		k = (s * j) % m;
	    else
		k = (-s * j) % m;

	    /* Convert to non-negative mod if needed */
	    if (k < 0)
		k += m;

	    for (i = 0; i < m; i++)
	    {
		if (k >= m)
		    k -= m;

		py[i] = px[k];

		k++;
	    }

	    px += m;
	    py += m;
	}
    }

    else
	mexErrMsgTxt("Invalid EXTMOD");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -