Exemplo n.º 1
0
        public bool Parse(string[] args)
        {
            var p = new Params(args);

            if (p.Default("-l", out Lambda, 6e-4).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-k", out KernelSize, 19).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-i", out Iterations, 1000).IsInvalid())
            {
                return(false);
            }
            if (p.Expect(out Src, "input image").IsBad())
            {
                return(false);
            }
            if (p.Has(out Dst).IsBad())
            {
                Dst = Aids.GetOutputName(Which);
                var root = Path.Combine(
                    Path.GetDirectoryName(Dst),
                    Path.GetFileNameWithoutExtension(Dst)
                    );
                DstKernel = root + "-kernel" + Path.GetExtension(Dst);
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adding New User to the database.
        /// </summary>
        /// <param name="fName"></param>
        /// <param name="lName"></param>
        /// <param name="userType"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="regDate"></param>
        /// <param name="address"></param>
        /// <param name="tel"></param>
        /// <param name="createdAt"></param>

        public static int addUser(string fName, string lName, string userType, string userName, string password, DateTime regDate, string address, string tel, DateTime createdAt, DateTime updatedAt)
        {
            try
            {
                int isAdd = 0;
                var Reg   = new UsersReg
                {
                    first_name = fName,
                    last_name  = lName,
                    user_type  = Aids.PickEnum(userType),
                    user_name  = userName,
                    password   = password.EncryptText("magic_encrypt1256"),
                    reg_date   = regDate,
                    address    = address,
                    tel        = tel,
                    created_at = createdAt,
                    updated_at = updatedAt
                };

                using (var context = new ApplicationDataContext())
                {
                    context.staffs.Add(Reg);
                    isAdd = context.SaveChanges();
                }
                return(isAdd);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Метод загрузки в память создаваемых объектов
        /// </summary>
        public static void Load()
        {
            int    s, p;
            Random rnd = new Random();

            _stars      = new Star[100];
            _background = new Background(new Point(0, 0), new Point(0, 0), new Size(0, 0));
            _asteroids  = new Asteroid[16];
            _planets    = new Planets[1];
            _bullet     = new Bullet(new Point(0, rnd.Next(0, GetHeight())), new Point(15, 0), new Size(30, 1));
            _ship       = new Ship(new Point(100, 400), new Point(50, 50), new Size(50, 50));
            _aids       = new Aids(new Point(0, rnd.Next(0, GetHeight())), new Point(20, 0), new Size(50, 50));

            for (int i = 0; i < _asteroids.Length; i++)
            {
                s             = rnd.Next(30, 90);
                p             = rnd.Next(50, 980);
                _asteroids[i] = new Asteroid(new Point(1920, p), new Point(15, 0), new Size(s, s), rnd.Next(4));
            }

            for (int i = 0; i < _stars.Length; i++)
            {
                s         = rnd.Next(1, 2);
                p         = rnd.Next(0, 1080);
                _stars[i] = new Star(new Point(1920, rnd.Next(0, Game.height)), new Point(s - i, s), new Size(s, s));
            }

            for (int i = 0; i < _planets.Length; i++)
            {
                s           = rnd.Next(80, 150);
                p           = rnd.Next(100, 800);
                _planets[i] = new Planets(new Point(1920, p), new Point(5, 0), new Size(s, s), rnd.Next(1));
            }
        }
Exemplo n.º 4
0
        public bool Parse(string[] args)
        {
            var p = new Params(args);

            if (p.Default("-h", out H, 3.0).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-t", out TemplateWindowSize, 7).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-s", out SearchWindowSize, 21).IsInvalid())
            {
                return(false);
            }
            if (p.Expect(out Src, "input image").IsBad())
            {
                return(false);
            }
            if (p.Has(out Dst).IsBad())
            {
                Dst = Aids.GetOutputName(Which);
            }
            return(true);
        }
Exemplo n.º 5
0
        public static void Usage(StringBuilder sb)
        {
            string name = Aids.AspectName(PickAspect.PrimeGen);

            sb
            .WL()
            .WL(0, $"{name} (gen|bits|bitsimg) [options]")
            .WL(1, "--debug", "Show debug messages (implies -v)")
            .WL(1, "-v", "Show extra information")
            .WL()
            .WL(0, "gen", "Generates a sequence of prime numbers and outputs one per line")
            .WL(1, "-t (type)", "Type of generator to use (leave empty to list the types)")
            .WL(1, "-s (number)", "Starting number for the generator (default 2)")
            .WL(1, "-e (number)", "Ending number for the generator (default 100)")
            .WL(1, "-f (file)", "Optional text file to store primes")
            //.WL()
            //.WL(0,"bits"       ,"Generate array of bits with primes as 1s and composites as 0s")
            //.WL(1,"-t (type)"  ,"Type of generator to use (leave empty to list the types)")
            //.WL(1,"-s (number)","Starting number for the generator (default 2)")
            //.WL(1,"-e (number)","Ending number for the generator (default 100) or use -l")
            //.WL(1,"-l (size)"  ,"Target size of file. can specify K/M/G/T/E suffixes or use -e")
            //.WL(1,"-f (file)"  ,"File to store the bits")
            //.WL()
            //.WL(0,"bitsimg"    ,"Generate an image using the prime number bit array process")
            //.WL(1,"-t (type)"  ,"Type of generator to use (leave empty to list the types)")
            //.WL(1,"-s (number)","Starting number for the generator (default 2)")
            //.WL(1,"-d (w) (h)" ,"Dimensions of the image (width and height)")
            //.WL(1,"-c (number)","Bits per color between 1 and 48 (default 1)")
            //.WL(1,"-p (file)"  ,"Color palette file to use for coloring")
            //.WL(1,"-f (file)"  ,"File to store image")
            ;
        }
Exemplo n.º 6
0
 public static int MakeSales(string userName, decimal salesAmount, DateTime salesDate, decimal discount, string payMethod)
 {
     try
     {
         int isInsert  = 0;
         var makeSales = new Sales
         {
             users_name     = userName,
             sales_amount   = salesAmount,
             sales_date     = salesDate,
             discount_given = discount,
             payment_method = Aids.PickPayEnum(payMethod)
         };
         using (var context = new ApplicationDataContext())
         {
             context.sales.Add(makeSales);
             isInsert = context.SaveChanges();;
         }
         return(isInsert);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 7
0
        public void Usage(StringBuilder sb)
        {
            string name = Aids.MethodName(Which);

            sb
            .WL()
            .WL(0, $"{name} [options] (input image) [output image]")
            .WL(1, "The function implements simple DCT-based (Discrete Cosine Transform) denoising, link: http://www.ipol.im/pub/art/2011/ys-dct/.")
            .WL(0, "Options:")
            .WL(1, "-s (double)", "Expected noise standard deviation.")
            .WL(1, "-p (int | 16)", "Size of block side where dct is computed.")
            ;
        }
Exemplo n.º 8
0
        public static void Usage(StringBuilder sb)
        {
            string name = Aids.AspectName(PickAspect.Factors);

            sb
            .WL()
            .WL(0, $"{name} (number) [options]")
            .WL(1, "-m (method)", "Use another method (default Basic)")
            .WL()
            .WL(0, "Methods:")
            .PrintEnum <PickMethod>(1)
            ;
        }
Exemplo n.º 9
0
        public bool Parse(string[] args)
        {
            var p = new Params(args);

            if (p.Default("-h", out FilterStregth, 1.0f).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-tw", out TWindow, 4).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-sw", out SWindow, 16).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-b1", out SWindow, 2500).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-b2", out SWindow, 400).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-gs", out SWindow, 8).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-ss", out SWindow, 1).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-k", out Beta, 2.0f).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-n", out PickNorm, NormWrap.L2).IsInvalid())
            {
                return(false);
            }

            if (p.Expect(out Src, "input image").IsBad())
            {
                return(false);
            }
            if (p.Has(out Dst).IsBad())
            {
                Dst = Aids.GetOutputName(Which);
            }
            return(true);
        }
Exemplo n.º 10
0
        public void Usage(StringBuilder sb)
        {
            string name = Aids.MethodName(Which);

            sb
            .WL()
            .WL(0, $"{name} [options] (input image) [input image] ...")
            .WL(1, "Denoise images using the Primal-dual algorithm. This algorithm is used for solving special types of variational problems (that is, finding a function to minimize some functional).")
            .WL(0, "Options:")
            .WL(1, "-o (string | *)", "Output image. If not provided a default name will be generated.")
            .WL(1, "-l (double | 1.0)", "Lambda scaling parameter. As it is enlarged, the smooth (blurred) images are treated more favorably than detailed (but maybe more noised) ones. Roughly speaking, as it becomes smaller, the result will be more blur but more sever outliers will be removed.")
            .WL(1, "-n (int | 30)", "Number of iterations that the algorithm will run. Of course, as more iterations as better, but it is hard to quantitatively refine this statement, so just use the default and increase it if the results are poor.")
            ;
        }
Exemplo n.º 11
0
        public void Usage(StringBuilder sb)
        {
            string name = Aids.MethodName(Which);

            sb
            .WL()
            .WL(0, $"{name} [options] (input image) [output image]")
            .WL(1, "Provably Robust Image Deconvolution Algorithm, a image deblurring algorithm that implements blind deconvolution")
            .WL(0, "Options:")
            .WL(1, "-l (double | 0.0006)", "Tunable regularization parameter.  Higher values of lambda will encourage more smoothness in the optimal sharp image")
            .WL(1, "-k (int | 19)", "Kernel size in pixels")
            .WL(1, "-i (int | 1000)", "Number of iterations");
            ;
        }
Exemplo n.º 12
0
        public void Usage(StringBuilder sb)
        {
            string name = Aids.MethodName(Which);

            sb
            .WL()
            .WL(0, $"{name} [options] (input image) [output image]")
            .WL(1, "Perform image denoising using Non-local Means Denoising algorithm: http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/ with several computational optimizations. Noise expected to be a gaussian white noise.")
            .WL(0, "Options:")
            .WL(1, "-h (float | 3.0)", "Parameter regulating filter strength. Big h value perfectly removes noise but also removes image details, smaller h value preserves details but also preserves some noise.")
            .WL(1, "-t (int | 7)", "Size in pixels of the template patch that is used to compute weights. Should be odd.")
            .WL(1, "-s (int | 21)", "Size in pixels of the window that is used to compute weighted average for given pixel. Should be odd. Affects performance linearly: greater searchWindowsSize -> greater denoising time.")
            ;
        }
Exemplo n.º 13
0
        public void Usage(StringBuilder sb)
        {
            string name = Aids.MethodName(Which);

            sb
            .WL()
            .WL(0, $"{name} [options] (input image) [output image]")
            .WL(1, "Perform image denoising using Non-local Means Denoising algorithm (modified for color image): http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/ with several computational optimizations. Noise expected to be a gaussian white noise. The function converts image to CIELAB colorspace and then separately denoise L and AB components with given h parameters using fastNlMeansDenoising function.")
            .WL(0, "Options:")
            .WL(1, "-h (float | 3.0)", "Parameter regulating filter strength. Big h value perfectly removes noise but also removes image details, smaller h value preserves details but also preserves some noise.")
            .WL(1, "-c (float | 3.0)", "The same as -h but for color components. For most images a value of 10 will be enough to remove colored noise and not distort colors.")
            .WL(1, "-t (int | 7)", "Size in pixels of the template patch that is used to compute weights. Should be odd.")
            .WL(1, "-s (int | 21)", "Size in pixels of the window that is used to compute weighted average for given pixel. Should be odd. Affects performance linearly: greater searchWindowsSize -> greater denoising time.")
            ;
        }
Exemplo n.º 14
0
        public static void Usage(StringBuilder sb)
        {
            string name = Aids.AspectName(PickAspect.AltMat);

            sb
            .WL()
            .WL(0, $"{name} (function) [number] [options]")
            .WL(1, "Implementations of some math functions using various numeric methods")
            .WL(0, "Options:")
            .WL(1, "-b (number)", "Series start number")
            .WL(1, "-e (number)", "Series end number")
            .WL(1, "-s (number)", "Series step amount")
            .WL(1, "-a (number)", "Accuracy (for functions that support it)")
            .WL(1, "-io", "Print both input and output")
            .WL()
            .WL(0, "Functions:")
            ;
            ListFuntions(sb);
        }
Exemplo n.º 15
0
        public static void Usage(StringBuilder sb)
        {
            string name = Aids.AspectName(PickAspect.SequenceGen);

            sb
            .WL()
            .WL(0, $"{name} (sequence) [options]")
            .WL(1, "A set of algorithms that can continuously produce digits of infinite series")
            .WL(0, "Options:")
            .WL(1, "-b (number)", "Output number in given base (if generator supports it)")
            .WL(1, "-d (number)", "Number of digits to print (default 1000)")
            .WL(1, "-d-", "Keep printing numbers until process is killed")
            .WL(1, "-f (file)", "Write digits to a file instead of standard out")
            .WL(1, "-v", "Show progress bar and stats")
            .WL(1, "-n", "Insert newlines periodically")
            .WL(1, "-nw", "Number of characters between newlines (default 80)")
            .WL()
            .WL(0, "Sequences:")
            ;
            AppendSequences(sb);
        }
Exemplo n.º 16
0
        public void Usage(StringBuilder sb)
        {
            string name = Aids.MethodName(Which);

            sb
            .WL()
            .WL(0, $"{name} [options] (input image) [output image]")
            .WL(1, "Performs image denoising using the Block-Matching and 3D-filtering algorithm http://www.cs.tut.fi/~foi/GCF-BM3D/BM3D_TIP_2007.pdf with several computational optimizations. Noise expected to be a gaussian white noise.")
            .WL(0, "Options:")
            .WL(1, "-h (float | 1.0)", "Filter strength. Big h value perfectly removes noise but also removes image details, smaller h value preserves details but also preserves some noise.")
            .WL(1, "-tw (int | 4)", "Size in pixels of the template patch that is used for block-matching. Should be power of 2.")
            .WL(1, "-sw (int | 16)", "Size in pixels of the window that is used to perform block-matching. Affect performance linearly: greater searchWindowsSize - greater denoising time. Must be larger than -tw. ")
            .WL(1, "-b1 (int | 2500)", "Block matching threshold for the first step of BM3D (hard thresholding), i.e. maximum distance for which two blocks are considered similar. Value expressed in euclidean distance.")
            .WL(1, "-b2 (int | 400)", "Block matching threshold for the second step of BM3D (Wiener filtering), i.e. maximum distance for which two blocks are considered similar. Value expressed in euclidean distance.")
            .WL(1, "-gs (int | 8)", "Maximum size of the 3D group for collaborative filtering.")
            .WL(1, "-ss (int | 1)", "Sliding step to process every next reference block.")
            .WL(1, "-k (float | 2.0)", "Kaiser window parameter that affects the sidelobe attenuation of the transform of the window. Kaiser window is used in order to reduce border effects. To prevent usage of the window, set this to zero.")
            .WL(1, "-n (normType | L2)", "Norm used to calculate distance between blocks. L2 is slower than L1 but yields more accurate results.")
            .WL(0, "NormTypes:")
            .PrintEnum <NormWrap>(1, false, GetNormDesc)
            ;
        }
Exemplo n.º 17
0
        public bool Parse(string[] args)
        {
            var p = new Params(args);

            if (p.Default("-p", out BlockSize, 16).IsInvalid())
            {
                return(false);
            }
            if (p.Expect("-s", out Sigma).IsBad())
            {
                return(false);
            }
            if (p.Expect(out Src, "input image").IsBad())
            {
                return(false);
            }
            if (p.Has(out Dst).IsBad())
            {
                Dst = Aids.GetOutputName(Which);
            }
            return(true);
        }
Exemplo n.º 18
0
        public bool Parse(string[] args)
        {
            var p = new Params(args);

            if (p.Default("-n", out Iterations, 30).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-l", out Lambda, 1.0).IsInvalid())
            {
                return(false);
            }
            if (p.Default("-o", out Dst).IsBad())
            {
                Dst = Aids.GetOutputName(Which);
            }
            SrcArr = p.Remaining();
            if (SrcArr.Length < 1)
            {
                Tell.MustProvideInput("one or more input images");
                return(false);
            }
            return(true);
        }
Exemplo n.º 19
0
 // Enum to String section
 static public string EnumToString(Aids a)
 {
     return(AidsLbl[(int)a]);
 }