void mexFunction(int nlhs,	     /* Num return vals on lhs */
                 mxArray *plhs[],    /* Matrices on lhs      */
                 int nrhs,	     /* Num args on rhs    */
                 const mxArray *prhs[]     /* Matrices on rhs */
                )
{
    double *mtx;
    double *newValues;
    double *doubleStartIndex;
    int i, startIndex, size;
    mxArray *arg;

    if (nrhs != 3) mexErrMsgTxt("requires 3 arguments.");

    /* ARG 1: MATRIX  */
    arg = prhs[0];
    if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix.");
    mtx = mxGetPr(arg);

    arg = prhs[1];
    if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix.");
    newValues = mxGetPr(arg);
    size = (int) mxGetM(arg) * mxGetN(arg);

    arg = prhs[2];
    if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix.");
    doubleStartIndex = mxGetPr(arg);
    startIndex = (int) doubleStartIndex[0];

    for (i=0; i<size; i++)
    {
        mtx[i+startIndex] = newValues[i];
    }
    return;
}
void mexFunction(int nlhs,	     /* Num return vals on lhs */
		 mxArray *plhs[],    /* Matrices on lhs      */
		 int nrhs,	     /* Num args on rhs    */
		 const mxArray *prhs[]     /* Matrices on rhs */
		 )
  {
  double *image, *lut, *res;
  double origin, increment;
  int x_dim, y_dim, lx_dim, ly_dim;
  int warnings = 1;
  mxArray *arg;
  double *mxMat;

  if (nrhs < 4 ) mexErrMsgTxt("requres  at least 4 args.");

  /* ARG 1: IMAGE  */
  arg = prhs[0];
  if notDblMtx(arg) mexErrMsgTxt("IMAGE arg must be a real non-sparse matrix.");
  image = mxGetPr(arg);
  x_dim = (int) mxGetM(arg); /* X is inner index! */
  y_dim = (int) mxGetN(arg);

  /* ARG 2: Lookup table */
  arg = prhs[1];
  if notDblMtx(arg) mexErrMsgTxt("LUT arg must be a real non-sparse matrix.");
  lut = mxGetPr(arg);
  lx_dim = (int) mxGetM(arg); /* X is inner index! */
  ly_dim = (int) mxGetN(arg);
  if ( (lx_dim != 1) && (ly_dim != 1) )
    mexErrMsgTxt("Lookup table must be a row or column vector.");

  /* ARG 3: ORIGIN */
  arg = prhs[2];
  if notDblMtx(arg) mexErrMsgTxt("ORIGIN arg must be a real scalar.");
  if (mxGetM(arg) * mxGetN(arg) != 1)
     mexErrMsgTxt("ORIGIN arg must be a real scalar.");
  mxMat = mxGetPr(arg);
  origin = *mxMat;

  /* ARG 4: INCREMENT */
  arg = prhs[3];
  if notDblMtx(arg) mexErrMsgTxt("INCREMENT arg must be a real scalar.");
  if (mxGetM(arg) * mxGetN(arg) != 1)
     mexErrMsgTxt("INCREMENT arg must be a real scalar.");
  mxMat = mxGetPr(arg);
  increment = *mxMat;

  /* ARG 5: WARNINGS */
  if (nrhs>4)
    {
    arg = prhs[4];
    if notDblMtx(arg) mexErrMsgTxt("WARINGS arg must be a real scalar.");
    if (mxGetM(arg) * mxGetN(arg) != 1)
      mexErrMsgTxt("WARNINGS arg must be a real scalar.");
    mxMat = mxGetPr(arg);
    warnings = (int) *mxMat;
    }
void mexFunction(int nlhs,	     /* Num return vals on lhs */
		 mxArray *plhs[],    /* Matrices on lhs      */
		 int nrhs,	     /* Num args on rhs    */
		 const mxArray *prhs[]     /* Matrices on rhs */
		 )
  {
  double *image,*filt, *temp, *result, *orig_filt;
  int x_fdim, y_fdim, x_idim, y_idim;
  int orig_x = 0, orig_y, x, y;
  int x_rdim, y_rdim;
  int x_start = 1;
  int x_step = 1;
  int y_start = 1;
  int y_step = 1;
  int x_stop, y_stop;
  const mxArray *arg0,*arg1,*arg3,*arg4,*arg6;
  double *mxMat;
  char edges[15] = "reflect1";

  if (nrhs<2) mexErrMsgTxt("requres at least 2 args.");

  /* ARG 1: IMAGE  */
  arg0 = prhs[0];
  if notDblMtx(arg0) mexErrMsgTxt("IMAGE arg must be a non-sparse double float matrix.");
  image = mxGetPr(arg0);
  x_idim = (int) mxGetM(arg0); /* X is inner index! */
  y_idim = (int) mxGetN(arg0);

  /* ARG 2: FILTER */
  arg1 = prhs[1];
  if notDblMtx(arg1) mexErrMsgTxt("FILTER arg must be non-sparse double float matrix.");  filt = mxGetPr(arg1);
  x_fdim = (int) mxGetM(arg1); 
  y_fdim = (int) mxGetN(arg1);

  /* ARG 3 (optional): EDGES */
  if (nrhs>2) 
	  {
  	  if (!mxIsChar(prhs[2]))
  	  	mexErrMsgTxt("EDGES arg must be a string.");
  	  mxGetString(prhs[2],edges,15);
	  }

  /* ARG 4 (optional): STEP */
  if (nrhs>3)
      {
      arg3 = prhs[3];
      if notDblMtx(arg3) mexErrMsgTxt("STEP arg must be double float matrix.");
      if (mxGetM(arg3) * mxGetN(arg3) != 2)
    	 mexErrMsgTxt("STEP arg must contain two elements.");
      mxMat = mxGetPr(arg3);
      x_step = (int) mxMat[0];
      y_step = (int) mxMat[1];
      if ((x_step<1) || (y_step<1))
         mexErrMsgTxt("STEP values must be greater than zero.");
      }
void mexFunction(int nlhs,	     /* Num return vals on lhs */
		 mxArray *plhs[],    /* Matrices on lhs      */
		 int nrhs,	     /* Num args on rhs    */
		 const mxArray *prhs[]     /* Matrices on rhs */
		 )
  {
  register double temp, mn, mx;
  register double *mtx;
  register int i, size;
  const mxArray *arg;

  if (nrhs != 1) mexErrMsgTxt("requires 1 argument.");

  /* ARG 1: MATRIX  */
  arg = prhs[0];
  if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix.");
  mtx = mxGetPr(arg);
  size = (int) mxGetM(arg) * mxGetN(arg);

  /* FIND min, max values of MTX */
  mn = *mtx;   mx = *mtx;  
  for (i=1; i<size; i++)
      {
      temp = mtx[i];
      if (temp < mn)
	mn = temp;
      else if (temp > mx)
	mx = temp;
      }

  plhs[0] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL);
  if (plhs[0] == NULL) mexErrMsgTxt("Error allocating result matrix");
  plhs[1] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL);
  if (plhs[1] == NULL) mexErrMsgTxt("Error allocating result matrix");
  mtx = mxGetPr(plhs[0]);
  mtx[0] = mn;
  mtx = mxGetPr(plhs[1]);
  mtx[0] = mx;

  return;
  }      
Exemple #5
0
void mexFunction(int nlhs,	     /* Num return vals on lhs */
		 mxArray *plhs[],    /* Matrices on lhs      */
		 int nrhs,	     /* Num args on rhs    */
		 const mxArray *prhs[]     /* Matrices on rhs */
		 )
  {
  double *mtx;
  int i, size;
  mxArray *arg;

  if (nrhs != 1) mexErrMsgTxt("requires 1 argument.");

  /* ARG 1: MATRIX  */
  arg = prhs[0];
  if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix.");
  mtx = mxGetPr(arg);
  size = (int) mxGetM(arg) * mxGetN(arg);

  for (i=0; i<size; i++)
      mtx[i] = mtx[i] * mtx[i];

  return;
  }      
Exemple #6
0
void mexFunction(int nlhs,	     /* Num return vals on lhs */
		 Matrix *plhs[],    /* Matrices on lhs      */
		 int nrhs,	     /* Num args on rhs    */
		 Matrix *prhs[]     /* Matrices on rhs */
		 )
  {
  double *image,*filt, *temp, *result;
  int x_fdim, y_fdim, x_idim, y_idim;
  int x_rdim, y_rdim;
  int x_start = 1;
  int x_step = 1;
  int y_start = 1;
  int y_step = 1;
  int x_stop, y_stop;
  Matrix *arg;
  double *mxMat;
  char edges[15] = "reflect1";
  
  if (nrhs<2) mexErrMsgTxt("requres at least 2 args.");

  /* ARG 1: IMAGE  */
  arg = prhs[0];
  if notDblMtx(arg) mexErrMsgTxt("IMAGE arg must be a non-sparse double float matrix.");
  image = mxGetPr(arg);
  x_idim = (int) mxGetM(arg); /* X is inner index! */
  y_idim = (int) mxGetN(arg);

  /* ARG 2: FILTER */
  arg = prhs[1];
  if notDblMtx(arg) mexErrMsgTxt("FILTER arg must be non-sparse double float matrix.");
  filt = mxGetPr(arg);
  x_fdim = (int) mxGetM(arg); 
  y_fdim = (int) mxGetN(arg);

  if ((x_fdim > x_idim) || (y_fdim > y_idim))
    {
    mexPrintf("Filter: [%d %d], Image: [%d %d]\n",x_fdim,y_fdim,x_idim,y_idim);
    mexErrMsgTxt("FILTER dimensions larger than IMAGE dimensions.");
    }

  /* ARG 3 (optional): EDGES */
  if (nrhs>2) 
      {
      if (!mxIsString(prhs[2]))
	mexErrMsgTxt("EDGES arg must be a string.");
      mxGetString(prhs[2],edges,15);
      }

  /* ARG 4 (optional): STEP */
  if (nrhs>3)
      {
      arg = prhs[3];
      if notDblMtx(arg) mexErrMsgTxt("STEP arg must be a double float matrix.");
      if (mxGetM(arg) * mxGetN(arg) != 2)
    	 mexErrMsgTxt("STEP arg must contain two elements.");
      mxMat = mxGetPr(arg);
      x_step = (int) mxMat[0];
      y_step = (int) mxMat[1];
      if ((x_step<1) || (y_step<1))
         mexErrMsgTxt("STEP values must be greater than zero.");
      }
Exemple #7
0
void mexFunction(int nlhs,	     /* Num return vals on lhs */
		 mxArray *plhs[],    /* Matrices on lhs      */
		 int nrhs,	     /* Num args on rhs    */
		 const mxArray *prhs[]     /* Matrices on rhs */
		 )
  {
  double *image,*filt, *result;
  int x_idim, y_idim, t_idim=1, n_idim=1;
  int x_fdim, y_fdim=1, t_fdim=1, n_fdim=1;
  int x_rdim, y_rdim, t_rdim, n_rdim;
  int x_step = 1;  /* default values */
  int y_step = 1;
  int t_step = 1;
  int rdims[4];
 
  mxArray *arg;
  double *mxMat;
  int dim;
  int const *pdim;
  if (nrhs<2) mexErrMsgTxt("requres at least 2 args.");

  /* ARG 1: IMAGE  */
  arg = prhs[0];
  if notDblMtx(arg) mexErrMsgTxt("IMAGE arg must be a non-sparse double float matrix.");
  image = mxGetPr(arg);
  
  dim =(int) mxGetNumberOfDimensions(arg);
  pdim = mxGetDimensions(arg);
  if ((dim < 2) || (dim > 4)) {
    mexErrMsgTxt("\n The IMAGE must have 2-4 dimensions! \n");
  }
 
  x_idim = (int) pdim[0]; /* X is inner index! */
  y_idim = (int) pdim[1];
  if (dim >= 3){
    t_idim = (int) pdim[2];
    if (dim == 4)
      n_idim = (int) pdim[3];
    }

/*  printf("%d, %d, %d, %d\n",x_idim,y_idim,t_idim,n_idim);*/

  /* ARG 2: FILTER */
  arg = prhs[1];
  if notDblMtx(arg) mexErrMsgTxt("FILTER arg must be non-sparse double float matrix.");
  filt = mxGetPr(arg);
 
  dim =(int) mxGetNumberOfDimensions(arg);
  pdim = mxGetDimensions(arg);
  x_fdim = (int) pdim[0]; 
  
  if (dim==2){
    y_fdim = (int) pdim[1];   
  } 
  if((dim==3) || (dim==4)){
    y_fdim = (int) pdim[1];  
    t_fdim = (int) pdim[2];
  }
  n_fdim = n_idim;
  
  if ((x_fdim > x_idim) || (y_fdim > y_idim) || (t_fdim > t_idim))
    {
    mexPrintf("Filter: [%d %d %d %d], Image: [%d %d %d %d]\n",
	      x_fdim,y_fdim,t_fdim, n_fdim,x_idim,y_idim,t_idim,n_idim);
    mexErrMsgTxt("FILTER dimensions larger than IMAGE dimensions.");
    }

  /* ARG 3 (optional): STEP */
  if (nrhs>2)
      {
      arg = prhs[2];
      if notDblMtx(arg) mexErrMsgTxt("STEP arg must be a double float matrix.");
      if (mxGetM(arg) * mxGetN(arg) != 3)
    	 mexErrMsgTxt("STEP vector must contain three elements.");
      mxMat = mxGetPr(arg);
      x_step = (int) mxMat[0];
      y_step = (int) mxMat[1];
      t_step = (int) mxMat[2];
      if ((x_step<1) || (y_step<1) || (t_step<1))
         mexErrMsgTxt("STEP values must be greater than zero.");
      }