Esempio n. 1
0
 public void SetPropertiesFromImageObject(ImageObject imageObject)
 {
     Area = imageObject.Area;
     Density = imageObject.Density;
     Elongation = imageObject.Elongation;
     MassCenter = imageObject.MassCenter;
     Density = imageObject.Density;
     Perimeter = imageObject.Perimeter;
 }
        private int GetClassIndex(FakeImageObject[] classes, ImageObject imageObject)
        {
            double[] distances = new double[classes.Count()];

            for (int i = 0; i < classes.Count(); i++)
            {
                distances[i] =
                    Math.Abs(areaCoefficient * (classes[i].Area - imageObject.Area)) +
                    Math.Abs(densityCoefficient * (classes[i].Density - imageObject.Density)) +
                    Math.Abs(elongationCoefficient * (classes[i].Elongation - imageObject.Elongation)) +
                    Math.Abs(perimeterCoefficient * (classes[i].Perimeter - imageObject.Perimeter)) +
                    Math.Abs(massCenterCoefficient * Math.Sqrt(
                                 (classes[i].MassCenter.X - imageObject.MassCenter.X) * (classes[i].MassCenter.X - imageObject.MassCenter.X) +
                                 (classes[i].MassCenter.Y - imageObject.MassCenter.Y) * (classes[i].MassCenter.Y - imageObject.MassCenter.Y))
                             );
            }

            return(Array.IndexOf(distances, distances.Min()));
        }
Esempio n. 3
0
        private int GetClassIndex(FakeImageObject[] classes, ImageObject imageObject)
        {
            double[] distances = new double[classes.Count()];

            for (int i = 0; i < classes.Count(); i++)
            {
                distances[i] =
                        Math.Abs(areaCoefficient * (classes[i].Area - imageObject.Area)) +
                        Math.Abs(densityCoefficient * (classes[i].Density - imageObject.Density)) +
                        Math.Abs(elongationCoefficient * (classes[i].Elongation - imageObject.Elongation)) +
                        Math.Abs(perimeterCoefficient * (classes[i].Perimeter - imageObject.Perimeter)) +
                        Math.Abs(massCenterCoefficient * Math.Sqrt(
                        (classes[i].MassCenter.X - imageObject.MassCenter.X) * (classes[i].MassCenter.X - imageObject.MassCenter.X) +
                        (classes[i].MassCenter.Y - imageObject.MassCenter.Y) * (classes[i].MassCenter.Y - imageObject.MassCenter.Y))
                        );
            }

            return Array.IndexOf(distances, distances.Min());
        }
Esempio n. 4
0
        public void SetPixelsToObjectGroupsWithFilter()
        {
            ImageObject[] objectArray = new ImageObject[this.GetGroupsNumber() + 1];
            objectArray[0] = new ImageObject();

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (objectArray[groupMap[x, y]] == null)
                    {
                        objectArray[groupMap[x, y]] = new ImageObject
                            {
                                GroupId = this.groupMap[x, y]
                            };
                    }

                    objectArray[groupMap[x, y]].AddPoint(new Point(x, y));

                    if (!(
                        IsGroupEqualToGroupnumber(x - 1, y, groupMap[x, y]) &&
                        IsGroupEqualToGroupnumber(x + 1, y, groupMap[x, y]) &&
                        IsGroupEqualToGroupnumber(x, y - 1, groupMap[x, y]) &&
                        IsGroupEqualToGroupnumber(x, y + 1, groupMap[x, y])))
                    {
                        objectArray[groupMap[x, y]].IncrementPerimeter();
                    }
                }
            }
            objectList = new List<ImageObject>();
            foreach (ImageObject imageObject in objectArray)
            {
                if (imageObject.Area == 0 || imageObject.GroupId == 1)
                {
                    continue;
                }
                if (imageObject.Area > minimalSquare)
                {
                    objectList.Add(imageObject);
                }
                else
                {
                    foreach (Point point in imageObject.Points)
                    {
                        groupMap[point.X, point.Y] = 1;
                    }
                }
            }
        }