Пример #1
0
 public void DrawTo(BImage img)
 {
     foreach (var p in Pixels)
     {
         img.Set(AverageColor, p);
     }
 }
Пример #2
0
        public bool DeleteWithSubEntities(Branch entity)
        {
            EfCoreCourseRepository courseRepository = new EfCoreCourseRepository();
            EfCoreBImageRepository bImageRepository = new EfCoreBImageRepository();

            using (var context = new CourseContext())
            {
                Branch branch = context.Branch.Where(i => i.BranchId == entity.BranchId)
                                .Include(i => i.BranchCourse)
                                .ThenInclude(i => i.Course)
                                .Include(i => i.BranchBImage)
                                .ThenInclude(i => i.BImage).FirstOrDefault();
                foreach (var courseId in branch.BranchCourse.Select(i => i.Course.CourseId))
                {
                    Course course = courseRepository.GetById(courseId);
                    courseRepository.Delete(course);
                }
                foreach (var bImageId in branch.BranchBImage.Select(i => i.BImage.BImageId))
                {
                    BImage bImage = bImageRepository.GetById(bImageId);
                    bImageRepository.Delete(bImage);
                }
                Delete(entity);
                return(true);
            }
        }
Пример #3
0
 public bool Update(BImage entity)
 {
     if (Validation(entity, true))
     {
         _bImageRepository.Update(entity);
         return(true);
     }
     return(false);
 }
Пример #4
0
            public static E Create(BImage img, Pixel p0, Pixel p1)
            {
                var e = new E();

                e.P0 = p0;
                e.P1 = p1;
                e.D  = p0.DistTo(p1, img);

                return(e);
            }
Пример #5
0
        bool isInOperations(IntPtr hWnd)
        {
            _screenshotSource = new ScreenshotSource(hWnd);
            screenshot        = Screenshot;
            var color4 = screenshot.Get(Pixel.Create(540, 1500));
            var color5 = screenshot.Get(Pixel.Create(420, 1500));

            _screenshotSource.Dispose();
            return((color4 == color5)
                ? true : false);
        }
Пример #6
0
        bool isInMenuAFK(IntPtr hWnd)
        {
            _screenshotSource = new ScreenshotSource(hWnd);
            screenshot        = Screenshot;
            var color4 = screenshot.Get(Pixel.Create(500, 560));
            var color5 = screenshot.Get(Pixel.Create(500, 600));

            _screenshotSource.Dispose();
            return((color4 == color5 && color4.R == 251)
                ? true : false);
        }
Пример #7
0
        bool isInMenu(IntPtr hWnd)
        {
            _screenshotSource = new ScreenshotSource(hWnd);
            screenshot        = Screenshot;
            var color4 = screenshot.Get(Pixel.Create(123, 166));
            var color5 = screenshot.Get(Pixel.Create(123, 371));

            _screenshotSource.Dispose();
            return((color4 == color5)
                ? true : false);
        }
Пример #8
0
        public Segment(BImage img, Pixel rootPixel)
        {
            _img = img;
            _w   = img.W;

            RootPixel = rootPixel;
            Pixels    = new List <Pixel>();

            IntegratedColor = new IntegratedColor();
            IntegratedPixel = new IntegratedPixel();
        }
Пример #9
0
        bool isInQueue(IntPtr hWnd)
        {
            _screenshotSource = new ScreenshotSource(hWnd);
            screenshot        = Screenshot;
            var color1 = screenshot.Get(Pixel.Create(455, 960));
            var color2 = screenshot.Get(Pixel.Create(615, 960));
            var color3 = screenshot.Get(Pixel.Create(500, 960));

            _screenshotSource.Dispose();
            return((color1 == color2 && color1 == color3)
                ? true : false);
        }
Пример #10
0
        bool isInLobby(IntPtr hWnd)
        {
            _screenshotSource = new ScreenshotSource(hWnd);
            screenshot        = _screenshotSource.Screenshot;
            var color1 = screenshot.Get(Pixel.Create(278, 162));
            var color2 = screenshot.Get(Pixel.Create(278, 228));
            var color3 = screenshot.Get(Pixel.Create(285, 500));

            _screenshotSource.Dispose();
            return((color1 == color2 && color1 == color3)
                ? true : false);
        }
Пример #11
0
        public void DrawAverageTo(BImage img, Color color)
        {
            var w = _img.W;
            var h = _img.H;

            var N = PixelNeighbours(AveragePixel, w, h);

            foreach (var n in N)
            {
                img.Set(color, n);
            }
            img.Set(color, AveragePixel);
        }
Пример #12
0
        public static Result DoSegmentation(BImage img, float smoothSigma, bool smoothMultitread, int segMinSize, float segTheshold, bool quadroPixel)
        {
            var w = img.W;
            var h = img.H;

            using (var tracker = new TimeTracker())
            {
                img = GaussSmooth.Smooth(img, smoothSigma, smoothMultitread);
                //Program.ShowData.SmoothTime = tracker.ElapsedSec;
            }

            ImageUniverse universe = null;

            using (var tracker = new TimeTracker())
            {
                universe = DoSegmentation(img, segTheshold, segMinSize, quadroPixel);
                //Program.ShowData.SegmentationTime = tracker.ElapsedSec;
            }

            var segments = new Dictionary <Pixel, Segment>();

            for (var i = 0; i < universe.Count; i++)
            {
                var pixel  = Pixel.CreateByI(i, w);
                var parent = Pixel.CreateByI(universe.Parent(i), w);

                if (!segments.TryGetValue(parent, out var segment))
                {
                    segment = new Segment(img, parent);
                    segments.Add(parent, segment);
                }

                segment.AddPixel(pixel);
            }

            var averageImage = new BImage(w, h);

            foreach (var s in segments.Values)
            {
                s.Realize();
                s.DrawTo(averageImage);
            }

            var result = new Result();

            result.Image         = averageImage;
            result.ImageUniverse = universe;
            result.Segments      = segments;
            return(result);
        }
Пример #13
0
        public static BImage Smooth(BImage img, float sigma, bool useMultiTreading = true)
        {
            if (Math.Abs(sigma) < 0.01f)
            {
                return(img);
            }

            var mask = Mask(sigma);
            var src  = new FloatBufferImage(img);

            var tmp = ConvolveMulti(src, mask, useMultiTreading ? Environment.ProcessorCount : 1);
            var res = ConvolveMulti(tmp, mask, useMultiTreading ? Environment.ProcessorCount : 1);

            return(res.ToBImage());
        }
Пример #14
0
        public void DrawBoundaryTo(BImage img, ImageUniverse u, Color color)
        {
            var w = _img.W;
            var h = _img.H;

            foreach (var p in Pixels)
            {
                var N = PixelNeighbours(p, w, h);
                if (N.All(n => u.Parent(n.Index(w)) == RootPixel.Index(w)))
                {
                    continue;
                }

                img.Set(color, p);
            }
        }
Пример #15
0
        private static E[] Edges(BImage img, bool quadro)
        {
            var w = img.W;
            var h = img.H;

            var index = 0;
            var e     = new E[w * h * 4];

            for (var j = 0; j < h; j++)
            {
                for (var i = 0; i < w; i++)
                {
                    if (i < w - 1)
                    {
                        e[index++] = E.Create(img,
                                              Pixel.Create(j, i),
                                              Pixel.Create(j, i + 1));
                    }
                    if (j < h - 1)
                    {
                        e[index++] = E.Create(img,
                                              Pixel.Create(j, i),
                                              Pixel.Create(j + 1, i));
                    }

                    if (!quadro)
                    {
                        continue;
                    }

                    if (i < w - 1 && j < h - 1)
                    {
                        e[index++] = E.Create(img,
                                              Pixel.Create(j, i),
                                              Pixel.Create(j + 1, i + 1));
                    }
                    if (i < w - 1 && j > 0)
                    {
                        e[index++] = E.Create(img,
                                              Pixel.Create(j, i),
                                              Pixel.Create(j - 1, i + 1));
                    }
                }
            }

            return(e);
        }
Пример #16
0
        public bool Validation(BImage entity, bool IdValidation)
        {
            bool isValid = true;

            if (IdValidation == true)
            {
                if (entity.BImageId == 0 || _bImageRepository.GetById(entity.BImageId) == null)
                {
                    ErrorMessage += "BImageId is Invalid."; isValid = false;
                }
            }
            if (string.IsNullOrEmpty(entity.Url))
            {
                ErrorMessage += "Image Url Is Empty \n";
                isValid       = false;
            }
            return(isValid);
        }
Пример #17
0
        public static ImageUniverse DoSegmentation(BImage img, float t, int minSize, bool quadro = true)
        {
            var w = img.W;
            var h = img.H;

            var e = Edges(img, quadro);
            var u = DoSegmentation(e, w, h, t);

            for (var i = 0; i < e.Length; i++)
            {
                int p0 = u.Parent(e[i].P0.Index(w));
                int p1 = u.Parent(e[i].P1.Index(w));
                if (p0 != p1 && (u.Size(p0) < minSize || u.Size(p1) < minSize))
                {
                    u.Join(p0, p1);
                }
            }

            return(u);
        }
Пример #18
0
    protected override void OnValidate()
    {
        base.OnValidate();

        image = GetComponentInChildren <BImage>();
    }