/*
 * File: main.c
 *
 * MATLAB Coder version            : 3.4
 * C/C++ source code generated on  : 27-Feb-2019 07:49:44
 */

/*************************************************************************/
/* This automatically generated example C main file shows how to call    */
/* entry-point functions that MATLAB Coder generated. You must customize */
/* this file for your application. Do not modify this file directly.     */
/* Instead, make a copy of this file, modify it, and integrate it into   */
/* your development environment.                                         */
/*                                                                       */
/* This file initializes entry-point function arguments to a default     */
/* size and value before calling the entry-point functions. It does      */
/* not store or use any values returned from the entry-point functions.  */
/* If necessary, it does pre-allocate memory for returned values.        */
/* You can use this file as a starting point for a main function that    */
/* you can deploy in your application.                                   */
/*                                                                       */
/* After you copy the file, and before you deploy it, you must make the  */
/* following changes:                                                    */
/* * For variable-size function arguments, change the example sizes to   */
/* the sizes that your application requires.                             */
/* * Change the example values of function arguments to the values that  */
/* your application requires.                                            */
/* * If the entry-point functions return values, store these values or   */
/* otherwise use them as required by your application.                   */
/*                                                                       */
/*************************************************************************/
/* Include Files */
#include "rt_nonfinite.h"
#include "MLS.h"
#include "main.h"
#include "MLS_terminate.h"
#include "MLS_emxAPI.h"
#include "MLS_initialize.h"

/* Function Declarations */
static void argInit_1x2_real_T(double result[2]);
static emxArray_char_T *argInit_1xUnbounded_char_T(void);
static void argInit_480x640x3_uint8_T(unsigned char result[921600]);
static emxArray_real_T *argInit_Unboundedx1_real_T(void);
static emxArray_real_T *argInit_Unboundedx2_real_T(void);
static char argInit_char_T(void);
static double argInit_real_T(void);
static struct0_T argInit_struct0_T(void);
static unsigned char argInit_uint8_T(void);
static emxArray_real_T *c_argInit_UnboundedxUnbounded_r(void);
static void main_MLS(void);

/* Function Definitions */

/*
 * Arguments    : double result[2]
 * Return Type  : void
 */
static void argInit_1x2_real_T(double result[2])
{
  int idx1;

  /* Loop over the array to initialize each element. */
  for (idx1 = 0; idx1 < 2; idx1++) {
    /* Set the value of the array element.
       Change this value to the value that the application requires. */
    result[idx1] = argInit_real_T();
  }
}

/*
 * Arguments    : void
 * Return Type  : emxArray_char_T *
 */
static emxArray_char_T *argInit_1xUnbounded_char_T(void)
{
  emxArray_char_T *result;
  static int iv1[2] = { 1, 2 };

  int idx1;

  /* Set the size of the array.
     Change this size to the value that the application requires. */
  result = emxCreateND_char_T(2, iv1);

  /* Loop over the array to initialize each element. */
  for (idx1 = 0; idx1 < result->size[1U]; idx1++) {
    /* Set the value of the array element.
       Change this value to the value that the application requires. */
    result->data[result->size[0] * idx1] = argInit_char_T();
  }

  return result;
}

/*
 * Arguments    : unsigned char result[921600]
 * Return Type  : void
 */
static void argInit_480x640x3_uint8_T(unsigned char result[921600])
{
  int idx0;
  int idx1;
  int idx2;

  /* Loop over the array to initialize each element. */
  for (idx0 = 0; idx0 < 480; idx0++) {
    for (idx1 = 0; idx1 < 640; idx1++) {
      for (idx2 = 0; idx2 < 3; idx2++) {
        /* Set the value of the array element.
           Change this value to the value that the application requires. */
        result[(idx0 + 480 * idx1) + 307200 * idx2] = argInit_uint8_T();
      }
    }
  }
}

/*
 * Arguments    : void
 * Return Type  : emxArray_real_T *
 */
static emxArray_real_T *argInit_Unboundedx1_real_T(void)
{
  emxArray_real_T *result;
  static int iv4[1] = { 2 };

  int idx0;

  /* Set the size of the array.
     Change this size to the value that the application requires. */
  result = emxCreateND_real_T(1, iv4);

  /* Loop over the array to initialize each element. */
  for (idx0 = 0; idx0 < result->size[0U]; idx0++) {
    /* Set the value of the array element.
       Change this value to the value that the application requires. */
    result->data[idx0] = argInit_real_T();
  }

  return result;
}

/*
 * Arguments    : void
 * Return Type  : emxArray_real_T *
 */
static emxArray_real_T *argInit_Unboundedx2_real_T(void)
{
  emxArray_real_T *result;
  static int iv2[2] = { 2, 2 };

  int idx0;
  int idx1;

  /* Set the size of the array.
     Change this size to the value that the application requires. */
  result = emxCreateND_real_T(2, iv2);

  /* Loop over the array to initialize each element. */
  for (idx0 = 0; idx0 < result->size[0U]; idx0++) {
    for (idx1 = 0; idx1 < 2; idx1++) {
      /* Set the value of the array element.
         Change this value to the value that the application requires. */
      result->data[idx0 + result->size[0] * idx1] = argInit_real_T();
    }
  }

  return result;
}

/*
 * Arguments    : void
 * Return Type  : char
 */
static char argInit_char_T(void)
{
  return '?';
}

/*
 * Arguments    : void
 * Return Type  : double
 */
static double argInit_real_T(void)
{
  return 0.0;
}

/*
 * Arguments    : void
 * Return Type  : struct0_T
 */
static struct0_T argInit_struct0_T(void)
{
  struct0_T result;

  /* Set the value of each structure field.
     Change this value to the value that the application requires. */
  result.w_i = c_argInit_UnboundedxUnbounded_r();
  result.sum_w_i = argInit_Unboundedx1_real_T();
  result.p_ast = argInit_Unboundedx2_real_T();
  result.Similarity = c_argInit_UnboundedxUnbounded_r();
  return result;
}

/*
 * Arguments    : void
 * Return Type  : unsigned char
 */
static unsigned char argInit_uint8_T(void)
{
  return 0;
}

/*
 * Arguments    : void
 * Return Type  : emxArray_real_T *
 */
static emxArray_real_T *c_argInit_UnboundedxUnbounded_r(void)
{
  emxArray_real_T *result;
  static int iv3[2] = { 2, 2 };

  int idx0;
  int idx1;

  /* Set the size of the array.
     Change this size to the value that the application requires. */
  result = emxCreateND_real_T(2, iv3);

  /* Loop over the array to initialize each element. */
  for (idx0 = 0; idx0 < result->size[0U]; idx0++) {
    for (idx1 = 0; idx1 < result->size[1U]; idx1++) {
      /* Set the value of the array element.
         Change this value to the value that the application requires. */
      result->data[idx0 + result->size[0] * idx1] = argInit_real_T();
    }
  }

  return result;
}

/*
 * Arguments    : void
 * Return Type  : void
 */
static void main_MLS(void)
{
  static unsigned char oldImg[921600];
  emxArray_char_T *type;
  double alpha;
  emxArray_real_T *p;
  emxArray_real_T *q;
  emxArray_real_T *v;
  double imgSize[2];
  double grid_size[2];
  struct0_T pre;
  static unsigned char newImg[921600];

  /* Initialize function 'MLS' input arguments. */
  /* Initialize function input argument 'oldImg'. */
  argInit_480x640x3_uint8_T(oldImg);

  /* Initialize function input argument 'type'. */
  type = argInit_1xUnbounded_char_T();
  alpha = argInit_real_T();

  /* Initialize function input argument 'p'. */
  p = argInit_Unboundedx2_real_T();

  /* Initialize function input argument 'q'. */
  q = argInit_Unboundedx2_real_T();

  /* Initialize function input argument 'v'. */
  v = argInit_Unboundedx2_real_T();

  /* Initialize function input argument 'imgSize'. */
  argInit_1x2_real_T(imgSize);

  /* Initialize function input argument 'grid_size'. */
  argInit_1x2_real_T(grid_size);

  /* Initialize function input argument 'pre'. */
  pre = argInit_struct0_T();

  /* Call the entry-point 'MLS'. */
  MLS(oldImg, type, alpha, p, q, v, imgSize, grid_size, &pre, newImg);
  emxDestroy_struct0_T(pre);
  emxDestroyArray_real_T(v);
  emxDestroyArray_real_T(q);
  emxDestroyArray_real_T(p);
  emxDestroyArray_char_T(type);
}

/*
 * Arguments    : int argc
 *                const char * const argv[]
 * Return Type  : int
 */
int main(int argc, const char * const argv[])
{
  (void)argc;
  (void)argv;

  /* Initialize the application.
     You do not need to do this more than one time. */
  MLS_initialize();

  /* Invoke the entry-point functions.
     You can call entry-point functions multiple times. */
  main_MLS();

  /* Terminate the application.
     You do not need to do this more than one time. */
  MLS_terminate();
  return 0;
}

/*
 * File trailer for main.c
 *
 * [EOF]
 */
