Пример #1
0
        public void CropObjects(int step, int cropDistance)
        {
            Bitmap            result  = Image.Bitmap.Invert();
            List <BlobEntity> objects = result.FindBlobs();

            foreach (BlobEntity blob in objects)
            {
                int objectSize = blob.Contour.Points.Count;
                if (objectSize < 2 * step)
                {
                    return;
                }

                //fix one point
                var syncTask = new Task(() =>
                {
                    System.Threading.Tasks.Parallel.For(0, objectSize, i =>
                    {
                        IntPoint startPoint = blob.Contour.Points[i];
                        //for each check one other point
                        for (int j = i; j < objectSize; j++)
                        {
                            int circleDist = Math.Min(j - i, objectSize - (j - i));
                            if (circleDist >= step)
                            {
                                IntPoint endPoint = blob.Contour.Points[j];
                                int distance      =
                                    (int)
                                    Math.Sqrt(Math.Pow((startPoint.X - endPoint.X), 2) +
                                              Math.Pow((startPoint.Y - endPoint.Y), 2));
                                if ((distance < cropDistance)) //optimisation equal
                                {
                                    Image.DrawGrayLine(startPoint, endPoint, 255);
                                }
                            }
                        }
                    });
                });

                syncTask.RunSynchronously();
            }
        }
        public Image Step14DrawUltraSoundApproximation(ref VerificationStatus result, int relativeEstimationLimit)
        {
            if (!_debugMode)
            {
                throw new Exception("Can`t use this method in production mode");
            }

            ReflectionedLine drawingLine = _workingUltrasoundModA.ApproxLine;
            SimpleGrayImage  approxImage = new SimpleGrayImage(_workingUltrasoundModA.Image.Data);

            IntPoint startPoint = new IntPoint(drawingLine.GetX(ModATopIndention), ModATopIndention);
            IntPoint endPoint   = new IntPoint(drawingLine.GetX(_workingUltrasoundModA.Image.Rows - ModABottomIndention),
                                               _workingUltrasoundModA.Image.Rows - ModABottomIndention);

            approxImage.DrawGrayLine(startPoint, endPoint, 128);

            _ultrasoundModeAStatus = _workingUltrasoundModA.RelativeEstimation > relativeEstimationLimit ? VerificationStatus.Correct : VerificationStatus.Incorrect;
            result = _ultrasoundModeAStatus;

            return(approxImage.Bitmap);
        }