context: /*
  * MATLAB Compiler: 4.16 (R2011b)
  * Date: Sat Nov 17 00:05:13 2012
  * Arguments: "-B" "macro_default" "-W"
  * "dotnet:ImageSegmentation,ImageSegmentation,0.0,private" "-T" "link:lib" "-d"
  * "E:\MCA\MATLAB Files\Workspace\ImageSegmentation\src" "-w"
  * "enable:specified_file_mismatch" "-w" "enable:repeated_file" "-w"
  * "enable:switch_ignored" "-w" "enable:missing_lib_sentinel" "-w" "enable:demo_license"
  * "-v" "class{ImageSegmentation:E:\MCA\MATLAB
  * Files\Workspace\componentCount.m,E:\MCA\MATLAB
  * Files\Workspace\imExtractComponents.m,E:\MCA\MATLAB Files\Workspace\imSegmentation.m}" 
  */
  using System;
  using System.Reflection;
  using System.IO;
  using MathWorks.MATLAB.NET.Arrays;
  using MathWorks.MATLAB.NET.Utility;
  
  #if SHARED
  [assembly: System.Reflection.AssemblyKeyFile(@"")]
  #endif
  
  namespace ImageSegmentation
  {
  
    /// <summary>
    /// The ImageSegmentation class provides a CLS compliant, MWArray interface to the
    /// M-functions contained in the files:
    /// <newpara></newpara>
    /// E:\MCA\MATLAB Files\Workspace\componentCount.m
    /// <newpara></newpara>
    /// E:\MCA\MATLAB Files\Workspace\imExtractComponents.m
    /// <newpara></newpara>
    /// E:\MCA\MATLAB Files\Workspace\imSegmentation.m
    /// <newpara></newpara>
    /// deployprint.m
    /// <newpara></newpara>
    /// printdlg.m
    /// </summary>
    /// <remarks>
    /// @Version 0.0
    /// </remarks>
    public class ImageSegmentation : IDisposable
    {
      #region Constructors
  
      /// <summary internal= "true">
      /// The static constructor instantiates and initializes the MATLAB Compiler Runtime
      /// instance.
      /// </summary>
      static ImageSegmentation()
      {
        if (MWMCR.MCRAppInitialized)
        {
          Assembly assembly= Assembly.GetExecutingAssembly();
  
          string ctfFilePath= assembly.Location;
  
          int lastDelimiter= ctfFilePath.LastIndexOf(@"\");
  
          ctfFilePath= ctfFilePath.Remove(lastDelimiter, (ctfFilePath.Length - lastDelimiter));
  
          string ctfFileName = "ImageSegmentation.ctf";
  
          Stream embeddedCtfStream = null;
  
          String[] resourceStrings = assembly.GetManifestResourceNames();
  
          foreach (String name in resourceStrings)
          {
            if (name.Contains(ctfFileName))
            {
              embeddedCtfStream = assembly.GetManifestResourceStream(name);
              break;
            }
          }
          mcr= new MWMCR("",
                         ctfFilePath, embeddedCtfStream, true);
        }
        else
        {
          throw new ApplicationException("MWArray assembly could not be initialized");
        }
      }
  
  
      /// <summary>
      /// Constructs a new instance of the ImageSegmentation class.
      /// </summary>
      public ImageSegmentation()
      {
      }
  
  
      #endregion Constructors
  
      #region Finalize
  
      /// <summary internal= "true">
      /// Class destructor called by the CLR garbage collector.
      /// </summary>
      ~ImageSegmentation()
      {
        Dispose(false);
      }
  
  
      /// <summary>
      /// Frees the native resources associated with this object
      /// </summary>
      public void Dispose()
      {
        Dispose(true);
  
        GC.SuppressFinalize(this);
      }
  
  
      /// <summary internal= "true">
      /// Internal dispose function
      /// </summary>
      protected virtual void Dispose(bool disposing)
      {
        if (!disposed)
        {
          disposed= true;
  
          if (disposing)
          {
            // Free managed resources;
          }
  
          // Free native resources
        }
      }
  
  
      #endregion Finalize
  
      #region Methods
  
      /// <summary>
      /// Provides a single output, 0-input MWArrayinterface to the componentCount
      /// M-function.
      /// </summary>
      /// <remarks>
      /// </remarks>
      /// <returns>An MWArray containing the first output argument.</returns>
      ///
      public MWArray componentCount()
      {
        return mcr.EvaluateFunction("componentCount", new MWArray[]{});
      }
  
  
      /// <summary>
      /// Provides a single output, 1-input MWArrayinterface to the componentCount
      /// M-function.
      /// </summary>
      /// <remarks>
      /// </remarks>
      /// <param name="imFile">Input argument #1</param>
      /// <returns>An MWArray containing the first output argument.</returns>
      ///
      public MWArray componentCount(MWArray imFile)
      {
        return mcr.EvaluateFunction("componentCount", imFile);
      }
  
  
      /// <summary>
      /// Provides a single output, 2-input MWArrayinterface to the componentCount
      /// M-function.
      /// </summary>
      /// <remarks>
      /// </remarks>
      /// <param name="imFile">Input argument #1</param>
      /// <param name="conn">Input argument #2</param>
      /// <returns>An MWArray containing the first output argument.</returns>
      ///
      public MWArray componentCount(MWArray imFile, MWArray conn)
      {
        return mcr.EvaluateFunction("componentCount", imFile, conn);
      }
  
  
      /// <summary>
      /// Provides the standard 0-input MWArray interface to the componentCount M-function.
      /// </summary>
      /// <remarks>
      /// </remarks>
      /// <param name="numArgsOut">The number of output arguments to return.</param>
      /// <returns>An Array of length "numArgsOut" containing the output
      /// arguments.</returns>
      ///
      public MWArray[] componentCount(int numArgsOut)
      {
        return mcr.EvaluateFunction(numArgsOut, "componentCount", new MWArray[]{});
      }
  
  
      /// <summary>
      /// Provides the standard 1-input MWArray interface to the componentCount M-function.
      /// </summary>
      /// <remarks>
      /// </remarks>
      /// <param name="numArgsOut">The number of output arguments to return.</param>
      /// <param name="imFile">Input argument #1</param>
      /// <returns>An Array of length "numArgsOut" containing the output
      /// arguments.</returns>
      ///
      public MWArray[] componentCount(int numArgsOut, MWArray imFile)
      {
        return mcr.EvaluateFunction(numArgsOut, "componentCount", imFile);
      }
  
  
      /// <summary>
      /// Provides the standard 2-input MWArray interface to the componentCount M-function.
      /// </summary>
      /// <remarks>
      /// </remarks>
      /// <param name="numArgsOut">The number of output arguments to return.</param>
      /// <param name="imFile">Input argument #1</param>
      /// <param name="conn">Input argument #2</param>
      /// <returns>An Array of length "numArgsOut" containing the output
      /// arguments.</returns>
      ///
      public MWArray[] componentCount(int numArgsOut, MWArray imFile, MWArray conn)
      {
        return mcr.EvaluateFunction(numArgsOut, "componentCount", imFile, conn);
      }
  
  
      /// <summary>
      /// Provides an interface for the componentCount function in which the input and
      /// output
      /// arguments are specified as an array of MWArrays.
      /// </summary>
      /// <remarks>
      /// This method will allocate and return by reference the output argument
      /// array.<newpara></newpara>
      /// </remarks>
      /// <param name="numArgsOut">The number of output arguments to return</param>
      /// <param name= "argsOut">Array of MWArray output arguments</param>
      /// <param name= "argsIn">Array of MWArray input arguments</param>
      ///
      public void componentCount(int numArgsOut, ref MWArray[] argsOut, MWArray[] argsIn)
      {
        mcr.EvaluateFunction("componentCount", numArgsOut, ref argsOut, argsIn);
      }
  
  
      /// <summary>
      /// Provides a void output, 0-input MWArrayinterface to the imExtractComponents
      /// M-function.
      /// </summary>
      /// <remarks>
      /// </remarks>
      ///
      public void imExtractComponents()
      {
        mcr.EvaluateFunction(0, "imExtractComponents", new MWArray[]{});
      }
  
  
      /// <summary>
      /// Provides a void output, 1-input MWArrayinterface to the imExtractComponents
      /// M-function.
      /// </summary>
      /// <remarks>
      /// </remarks>
      /// <param name="imFile">Input argument #1</param>
      ///
      public void imExtractComponents(MWArray imFile)
      {
  
gt:       mcr.EvaluateFunction(0, "imExtractComponents", imFile);