public InterestPointDrawer(Bitmap background, SRegion[] regions)
     : base(background, regions)
 {
     Color c = Color.FromArgb(125, Color.Red);
     pen = new Pen(c);
     brush = new SolidBrush(c);
 }
        public void Apply(ref SRegion[] regions)
        {
            float count = (float)base.Count(regions);
            List<SRegion> temp = new List<SRegion>();

            unsafe
            {
                int* max = (int*)regions.Length;
                int* min = (int*)0;
                int incr = 1;
                for (int* i = min; i < max; i = (int*)((int)i + incr))
                {
                    int id = (int)i;
                    SRegion region = regions[id];

                    float size = (float)region.Size / count;
                    if (size > this.minMargin & size < this.maxMargin)
                        temp.Add(region);
                }
            }

            SRegion[] result = new SRegion[temp.Count];
            temp.CopyTo(result);
            regions = result;
        }
 public static bool IsRegionGroup(SRegion region1, SRegion region2)
 {
     if (region1.RegionRectangle.IntersectsWith(region2.RegionRectangle))
         return true;
     else
         return false;
 }
        public void Apply(ref SRegion[] regions)
        {
            List<SRegion> a = new List<SRegion>();
            List<SRegion> b = new List<SRegion>();
            List<SRegion> c = new List<SRegion>();

            TotalRegionsSize = base.Count(regions);

            foreach (SRegion region in regions)
            {
                float sizePercent = (float)region.Size / (float)TotalRegionsSize * 100F;
                if (sizePercent > 80)
                {
                    a.Add(region);
                }
                else if (sizePercent > 60)
                {
                    b.Add(region);
                }
                else
                {
                    c.Add(region);
                }
            }

            A = new SRegion[a.Count];
            B = new SRegion[b.Count];
            C = new SRegion[c.Count];

            a.CopyTo(A);
            b.CopyTo(B);
            c.CopyTo(C);
        }
 public static bool IsRegionFace(SRegion region)
 {
     if (region.FillPercent > 0.45 & region.FillPercent < 0.8 & region.BoxRate > 0.4F & region.BoxRate < 1.0F)
         return true;
     else
         return false;
 }
        public static void DrawSkinUnsafe(Graphics layer, Bitmap background, SRegion region)
        {
            drawSkin_background = background;
            drawSkin_layer = layer;
            drawSkin_region = region;

            background.UnsafeScan(new UnsafeScanHandler(UnsafeReadBackLayer), ImageLockMode.ReadOnly);
        }
        public void Apply(SRegion region)
        {
            ErosionRegionFilter erosion = new ErosionRegionFilter(structElement, structElementSize);
            erosion.Apply(region);

            DilationRegionFilter dilation = new DilationRegionFilter(structElement, structElementSize);
            dilation.Apply(region);
        }
Esempio n. 8
0
        public RegionDrawer(Bitmap background, List<SRegion> regions)
        {
            SRegion[] regionsArray = new SRegion[regions.Count];
            regions.CopyTo(regionsArray);

            this.regions = regionsArray;
            this.Background = background;

            Initialize(regionsArray);
        }
        public int Count(SRegion[] regions)
        {
            int count = 0;

            foreach (SRegion region in regions)
            {
                count += region.Size;
            }

            return count;
        }
Esempio n. 10
0
 protected virtual string GetClauseForCompareToSchoolsDistrict(
     string OrigFullKey,
     S4orALL S4orALL,
     CompareTo compareTo,
     OrgLevel orgLevel,
     string SCounty,
     string SAthleticConf,
     string SCESA,
     SRegion SRegion,
     out bool useFullkeys)
 {
     useFullkeys = false;
     return(String.Empty);
 }
Esempio n. 11
0
        public override SRegion[] GetRegions()
        {
            List<SRegion> faces = new List<SRegion>();

            for (int i = 0; i < Labeler.Regions.Length; i++)
            {
                if (IsRegionFace(Labeler.Regions[i]))
                    faces.Add(Labeler.Regions[i]);
            }

            SRegion[] result = new SRegion[faces.Count];
            faces.CopyTo(result, 0);
            return result;
        }
 protected override void DrawSkin(Graphics layer, SRegion region, int alfa)
 {
     Color c = Color.White;
     for (int x = 0; x < size.Width; x++)
     {
         for (int y = 0; y < size.Height; y++)
         {
             if (region[x, y])
             {
                 byte br = (byte)(backLayer.GetPixel(x, y).GetBrightness() * 255);
                 c = Color.FromArgb(br, br, br);
                 layer.DrawRectangle(new Pen(c), x, y, 1, 1);
             }
         }
     }
 }
 public void Apply(ref SRegion[] regions)
 {
     bool sorted = false;
     while (!sorted)
     {
         sorted = true;
         for (int i = 0; i < regions.Length - 1; i++)
         {
             if (regions[i].Size < regions[i + 1].Size)
             {
                 sorted = false;
                 SRegion temp = regions[i];
                 regions[i] = regions[i + 1];
                 regions[i + 1] = temp;
             }
         }
     }
 }
        public void Apply(SRegion region)
        {
            Rectangle bounds = region.RegionRectangle;
            unsafe
            {
                int dilationCenterX =   (structElementSize.Width - 1) / 2;
                int dilationCenterY =   (structElementSize.Height - 1) / 2;
                int dilationMaxX =      structElementSize.Width - 1;
                int dilationMaxY =      structElementSize.Height - 1;

                int* _dilationCenterX = (int*)dilationCenterX;
                int* _dilationCenterY = (int*)dilationCenterY;
                int* _dilationMaxX = (int*)dilationMaxX;
                int* _dilationMaxY = (int*)dilationMaxX;

                int* x_min = (int*)bounds.X;
                int* x_max = (int*)(bounds.X + bounds.Width - (int)_dilationCenterX);
                int* y_min = (int*)bounds.Y;
                int* y_max = (int*)(bounds.Y + bounds.Height - (int)_dilationCenterY);

                for (int* x = x_min; x < x_max; x++)
                {
                    for (int* y = y_min; y < y_max; y++)
                    {
                        bool bitVal = region[(int)x, (int)y];

                        for (int* sX = (int*)0; sX < _dilationMaxX; sX++)
                        {
                            for (int* sY = (int*)0; sY < _dilationMaxY; sY++)
                            {
                                if (structElement[(int)sX, (int)sY] & region[(int)x + (int)sX, (int)y + (int)sY])
                                {
                                    region.AddPoint((int)x + dilationCenterX, (int)y + dilationCenterY);
                                }
                            }
                        }
                    }
                }
            }
        }
        protected override void DrawRegion(int index, SRegion r, Graphics regionLayer)
        {
            base.DrawRegion(index, r, regionLayer);

            Rectangle frame = new Rectangle(new Point(0, 0), base.Background.Size);
            for (int x = frame.Left + rad + 1; x < frame.Size.Width - rad - 1; x++)
            {
                for (int y = frame.Top + rad + 1; y < frame.Size.Height - rad - 1; y++)
                {
                    bool ab = r[x + rad, y + rad];
                    bool bc = r[x + rad, y - rad];
                    bool cd = r[x - rad, y - rad];
                    bool da = r[x - rad, y + rad];

                    bool a = true, b = true, c = true, d = true;
                    int p = 0;

                    while (p < rad)
                    {
                        a &= r[x, y + p];
                        b &= r[x + p, y];
                        c &= r[x, y - p];
                        d &= r[x - p, y];
                        p++;
                    }

                    if (
                        (a & b & ab & !c & !d & !bc & !cd & !da) |
                        (b & c & bc & !a & !d & !ab & !cd & !da) |
                        (c & d & cd & !a & !b & !ab & !bc & !da) |
                        (a & d & da & !b & !c & !ab & !bc & !cd)
                        )
                    {
                        this.DrawCircle(regionLayer, new Point(x, y), rad, pen);
                    }
                }
            }
        }
Esempio n. 16
0
        protected virtual void DrawFrame(Graphics layer, SRegion region)
        {
            layer.DrawRectangle(Pens.LimeGreen, region.RegionRectangle);

            if ((InfoLayers & InfoLayerModes.REGIONNUMBER) == InfoLayerModes.REGIONNUMBER)
            {
                layer.PageUnit = GraphicsUnit.Display;
                Font f = new Font("Arial", 8.0f);
                string s = region.RegionIndex.ToString();
                RectangleF r = new RectangleF(region.RegionRectangle.Location, layer.MeasureString(s, f));

                layer.FillRectangle(Brushes.LimeGreen, r);
                layer.DrawString(s, f, Brushes.White, r);
            }
        }
 private void DrawPercentInfo(Graphics layer, SRegion region)
 {
     layer.PageUnit = GraphicsUnit.Display;
     float percent = (float)region.Size / ((float)size.Width * (float)size.Height) * 100.0F;
     Font f = new Font("Arial", 10);
     Point p = region.Center;
     layer.DrawString(
         string.Format(
             "Size: {0}% \r\nFill: {1}% \r\nBoxRate: {2}\r\n",
             new string[]{
             percent.ToString("0.00"),
             region.FillPercent.ToString("0.00"),
             region.BoxRate.ToString("0.00")
             }),
         f,
         Brushes.Black,
         new Point(p.X + 2, p.Y - 2));
 }
 private void DrawFrame(Graphics layer, SRegion region)
 {
     layer.DrawRectangle(Pens.LimeGreen, region.RegionRectangle);
 }
        private unsafe void CreateRegionCollection()
        {
            ///Create regions collection
            Dictionary<int, SRegion> regionDictionary = new Dictionary<int, SRegion>();
            unchecked
            {
                for (int x = 0; x < Image.Size.Width; x++)
                {
                    for (int y = 0; y < Image.Size.Height; y++)
                    {
                        int regionId = binaryMask[x, y];
                        if (regionId > 0)
                        {
                            if (regionDictionary.ContainsKey(regionId))
                            {
                                regionDictionary[regionId].AddPoint(x, y);
                            }
                            else
                            {
                                SRegion region = new SRegion(ref binaryMask, regionId, base.Image.Size);
                                region.AddPoint(x, y);
                                regionDictionary.Add(regionId, region);
                            }
                        }
                    }
                }
            }

            ///Convert region connection to array of regions
            regions = new SRegion[regionDictionary.Count];
            int index = 0;
            foreach (SRegion r in regionDictionary.Values)
            {
                regions[index] = r;
                index++;
            }
        }
        private void DrawRegion(Graphics layer, Color color, SRegion region)
        {
            Brush brush = Brushes.LimeGreen;
            Brush regionBrush = new SolidBrush(color);

            for (int x = 0; x < size.Width; x++)
            {
                for (int y = 0; y < size.Height; y++)
                {
                    if (region[x, y])
                    {
                        layer.FillRectangle(regionBrush, x, y, 1, 1);
                    }
                }
            }
        }
 public BrightlessDrawer(Bitmap background, SRegion[] regions)
     : base(background, regions)
 {
     ;
 }
 private void DrawSkin(Graphics layer, SRegion region)
 {
     LayerDrawer.DrawSkinUnsafe(layer, backLayer, region);
 }
Esempio n. 23
0
 public RegionDrawer(Bitmap background, SRegion[] regions)
 {
     this.Background = background;
     Initialize(regions);
 }
 public AsynchronousActionsComletedEventArgs(Exception error, bool cancelled, object userState, SRegion[] regions)
     : base(error, cancelled, userState)
 {
     this.Regions = regions;
 }
Esempio n. 25
0
        protected virtual void DrawSkin(Graphics layer, SRegion region, int alfa)
        {
            Color c = Color.White;
            for (int x = 0; x < size.Width; x++)
            {
                for (int y = 0; y < size.Height; y++)
                {
                    if (region[x, y])
                    {
                        c = backLayer.GetPixel(x, y);

                        if (alfa != 255)
                            c = Color.FromArgb(alfa, c.R, c.G, c.B);

                        layer.DrawRectangle(new Pen(c), x, y, 1, 1);
                    }
                }
            }
        }
Esempio n. 26
0
 protected void Initialize(SRegion[] regions)
 {
     this.SkinLayerTransparent = 255;
     this.size = Background.Size;
     this.backLayer = new Bitmap(Background, size.Width, size.Height);
     this.drawLayer = new Bitmap(size.Width, size.Height);
     this.frontLayer = Graphics.FromImage((Image)drawLayer);
     this.regions = regions;
 }
 public void Apply(SRegion region)
 {
     ;
 }
Esempio n. 28
0
        protected virtual void DrawRegion(Graphics layer, Color color, int alfa, SRegion region)
        {
            if (alfa != 255)
                color = Color.FromArgb(alfa, color.R, color.G, color.B);

            Brush brush = Brushes.LimeGreen;
            Brush regionBrush = new SolidBrush(color);

            for (int x = 0; x < size.Width; x++)
            {
                for (int y = 0; y < size.Height; y++)
                {
                    if (region[x, y])
                    {
                        layer.FillRectangle(regionBrush, x, y, 1, 1);
                    }
                }
            }
        }
Esempio n. 29
0
        protected virtual void DrawRegion(int index, SRegion r, Graphics regionLayer)
        {
            switch (SkinLayer)
            {
                case SkinLayerMode.SKIN:
                    DrawSkin(regionLayer, r, SkinLayerTransparent);
                    break;

                case SkinLayerMode.COLORMASK:
                    DrawRegion(regionLayer, colors[(index % colors.Length)], SkinLayerTransparent, r);
                    break;

                case SkinLayerMode.BLACKMASK:
                    DrawRegion(regionLayer, Color.Black, SkinLayerTransparent, r);
                    break;
            }

            if ((InfoLayers & InfoLayerModes.CENTER) == InfoLayerModes.CENTER)
                DrawCenterPoint(regionLayer, r);

            if ((InfoLayers & InfoLayerModes.FRAME) == InfoLayerModes.FRAME)
                DrawFrame(regionLayer, r);

            if ((InfoLayers & InfoLayerModes.INFORMATION) == InfoLayerModes.INFORMATION)
                DrawInformation(regionLayer, r);
        }
Esempio n. 30
0
        protected virtual void DrawInformation(Graphics layer, SRegion region)
        {
            layer.PageUnit = GraphicsUnit.Display;
            Font f = new Font("Arial", 8);
            Point p = region.Center;

            float percent = (float)region.Size / ((float)size.Width * (float)size.Height) * 100.0F;

            StringBuilder str = new StringBuilder();

            if ((InfoLayers & InfoLayerModes.SIZE) == InfoLayerModes.SIZE)
            {
                str.AppendFormat("Size: {0}%\r\n", percent.ToString("0.00"));
                str.AppendFormat("Size: {0}pts\r\n", region.Size);
            }

            if ((InfoLayers & InfoLayerModes.FILLPERCENT) == InfoLayerModes.FILLPERCENT)
                str.AppendFormat("Fill Percent: {0}\r\n", region.FillPercent.ToString("0.00"));
            if ((InfoLayers & InfoLayerModes.BOXRATE) == InfoLayerModes.BOXRATE)
                str.AppendFormat("Box Rate: {0}\r\n", region.BoxRate.ToString("0.00"));
            if ((InfoLayers & InfoLayerModes.COMPACTNESS) == InfoLayerModes.COMPACTNESS)
                str.AppendFormat("Compactness: {0}\r\n", region.Compactness.ToString("0.00"));
            if ((InfoLayers & InfoLayerModes.ORENTATION) == InfoLayerModes.ORENTATION)
                str.AppendFormat("Orentation: {0}\r\n", region.Orentation.ToString("0.00"));
            if ((InfoLayers & InfoLayerModes.ENLONGATION) == InfoLayerModes.ENLONGATION)
                str.AppendFormat("Enlongation: {0}\r\n", region.Enlongation.ToString("0.00"));
            if ((InfoLayers & InfoLayerModes.EDGELENGHT) == InfoLayerModes.EDGELENGHT)
                str.AppendFormat("Edge Length: {0}\r\n", region.EdgeLength.ToString("0.00"));

            layer.DrawString(
                str.ToString(),
                f,
                Brushes.Blue,
                new Point(p.X + 2, p.Y - 2));
        }
Esempio n. 31
0
 protected virtual void DrawCenterPoint(Graphics layer, SRegion region)
 {
     DrawPoint(layer, region.Center, region.Orentation, Pens.LimeGreen);
 }