Пример #1
0
        public static Bitmap MorphologySimpleBinarization(this Bitmap image, int morphologyKernel, byte morphologyThreshold)
        {
            if (image.PixelFormat != PixelFormat.Format8bppIndexed)
            {
                throw new NotSupportedException("Filter can be applied to binary 8bpp images only");
            }
            Erosion morphologyErosion   = new Erosion();
            Bitmap  tempMorphologyImage = morphologyErosion.Apply(image);

            for (int i = 0; i < morphologyKernel - 1; i++)
            {
                tempMorphologyImage = morphologyErosion.Apply(tempMorphologyImage);
            }
            SimpleGrayImage morphologyImage = new SimpleGrayImage(tempMorphologyImage);

            OtsuThreshold   thresholdFilter = new OtsuThreshold();
            SimpleGrayImage otcuImage       = new SimpleGrayImage(thresholdFilter.Apply(image));

            for (int i = 0; i < morphologyImage.Cols; i++)
            {
                for (int j = 0; j < morphologyImage.Rows; j++)
                {
                    if (morphologyImage.Data[j, i] > morphologyThreshold)
                    {
                        morphologyImage.Data[j, i] = 255;
                    }
                    else
                    {
                        morphologyImage.Data[j, i] = otcuImage.Data[j, i];
                    }
                }
            }
            return(morphologyImage.Bitmap);
        }
Пример #2
0
 public KuwaharaPixelProcessing(int x, int y, SimpleGrayImage image, int kernelSize = 2)
 {
     _x      = x;
     _y      = y;
     _image  = image;
     _kernel = kernelSize;
 }
 public KuwaharaRegion(Point centerPoint, Point regionPoint, SimpleGrayImage image)
 {
     _minX             = Math.Min(centerPoint.X, regionPoint.X);
     _maxX             = Math.Max(centerPoint.X, regionPoint.X);
     _minY             = Math.Min(centerPoint.Y, regionPoint.Y);
     _maxY             = Math.Max(centerPoint.Y, regionPoint.Y);
     _image            = image;
     _numberOfElements = (_maxX - _minX + 1) * (_maxY - _minY + 1);
 }
Пример #4
0
        public LgbtRegion(Point centerPoint, int radius, SimpleGrayImage image)
        {
            _image = image;
            //_image = new SimpleGrayImage(image.Mat);

            _minX             = Math.Max(centerPoint.X - radius, 0);
            _maxX             = Math.Min(centerPoint.X + radius, _image.Cols - 1);
            _minY             = Math.Max(centerPoint.Y - radius, 0);
            _maxY             = Math.Min(centerPoint.Y + radius, _image.Rows - 1);
            _numberOfElements = (_maxX - _minX + 1) * (_maxY - _minY + 1);
        }
        public LgbtPixelProcessing(int y, int x, SimpleGrayImage image, double k, int localRadius, int globalRadius, byte globalThreshold)
        {
            _x = x;
            _y = y;
            _k = k;

            _image = image;
            //_image = new SimpleGrayImage(image.Mat);

            _localRadius     = localRadius;
            _globalRadius    = globalRadius;
            _globalThreshold = globalThreshold;
        }
        public Image Step12DrawBadLines(ref VerificationStatus result, int badLinesLimit)
        {
            if (!_debugMode)
            {
                throw new Exception("Can`t use this method in production mode");
            }
            List <int>      badLines = _workingUltrasoundModM.DeviationStreakLines;
            SimpleGrayImage rez      = new SimpleGrayImage(_workingUltrasoundModM.Image.Data);

            badLines.ForEach(line => rez.DrawHorisontalGrayLine(0, _workingUltrasoundModM.Image.Cols - 1, line, 0));

            _ultrasoundModeMStatus = badLines.Count < badLinesLimit ? VerificationStatus.Correct : VerificationStatus.Incorrect;
            result = _ultrasoundModeMStatus;

            return(rez.Bitmap);
        }
Пример #7
0
        public UltrasoundModM(double deviationThreshold, int deviationStreakSize, SimpleGrayImage image, int topIndention, int bottomIndention)
        {
            Image                 = image;
            _topLine              = topIndention;
            _bottomLine           = image.Rows - bottomIndention;
            _deviationStreakLines = new List <int>();
            _deviations           = new double[image.Rows];
            _expectations         = new double[image.Rows];
            _deviationStreakSize  = deviationStreakSize;
            _deviationThreshold   = deviationThreshold;
            _iqr = new int[Image.Rows];

            SetExpectations();
            SetDeviations();
            SetIqr();
        }
        public Image Step15DrawBrightLines(ref VerificationStatus result, int threshold, int brightPixelLimit, int brightLinesLimit)
        {
            if (!_debugMode)
            {
                throw new Exception("Can`t use this method in production mode");
            }

            List <int>      briteLines = _workingUltrasoundModM.getBrightLines(threshold, brightPixelLimit);
            SimpleGrayImage rez        = new SimpleGrayImage(_workingUltrasoundModM.Image.Data);

            briteLines.ForEach(line => rez.DrawHorisontalGrayLine(0, _workingUltrasoundModM.Image.Cols - 1, line, 0));

            _ultrasoundModeMStatus = briteLines.Count < brightLinesLimit ? VerificationStatus.Correct : VerificationStatus.Incorrect;
            result = _ultrasoundModeMStatus;

            return(rez.Bitmap);
        }
        public SimpleGrayImage Apply(SimpleGrayImage image)
        {
            SimpleGrayImage source   = image;
            var             syncTask = new Task(() =>
            {
                Parallel.For(0, image.Rows, columnCounter =>
                {
                    for (int rowCounter = 0; rowCounter < image.Cols; rowCounter++)
                    {
                        KuwaharaPixelProcessing pixelProcessor = new KuwaharaPixelProcessing(rowCounter, columnCounter, source, _kernel);
                        image.Data[columnCounter, rowCounter]  = pixelProcessor.CalculatedPixelValue();
                    }
                });
            });

            syncTask.RunSynchronously();

            return(image);
        }
        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);
        }
Пример #11
0
        public static Bitmap MorphologyNiblackBinarization(this Bitmap image, double k, int radius, int morphologyKernel, byte globalThreshold)
        {
            if (image.PixelFormat != PixelFormat.Format8bppIndexed)
            {
                throw new NotSupportedException("Filter can be applied to binary 8bpp images only");
            }
            Erosion morphologyErosion   = new Erosion();
            Bitmap  tempMorphologyImage = morphologyErosion.Apply(image);

            for (int i = 0; i < morphologyKernel - 1; i++)
            {
                tempMorphologyImage = morphologyErosion.Apply(tempMorphologyImage);
            }
            SimpleGrayImage morphologyImage = new SimpleGrayImage(tempMorphologyImage);

            var threshold = new NiblackThreshold()
            {
                K = k, Radius = radius
            };
            SimpleGrayImage localBinImage = new SimpleGrayImage(threshold.Apply(image));

            for (int i = 0; i < morphologyImage.Cols; i++)
            {
                for (int j = 0; j < morphologyImage.Rows; j++)
                {
                    if (morphologyImage.Data[j, i] > globalThreshold)
                    {
                        morphologyImage.Data[j, i] = 255;
                    }
                    else
                    {
                        morphologyImage.Data[j, i] = localBinImage.Data[j, i];
                    }
                }
            }
            return(morphologyImage.Bitmap);
        }
        public SimpleGrayImage Apply(SimpleGrayImage image)
        {
            //SimpleGrayImage source =  image;
            SimpleGrayImage source = new SimpleGrayImage(image.Data);

            /*Parallel.For(0, image.Rows, columnCounter =>
             * {
             *  for (int rowCounter = 0; rowCounter < image.Cols; rowCounter++)
             *  {
             *      //LgbtPixelProcessing pixelProcessor = new LgbtPixelProcessing(rowCounter, columnCounter, image, k, localRadius, globalRadius, globalThreshold);
             *      //image.Data[columnCounter, rowCounter] = pixelProcessor.CalculatedPixelValue();
             *      LgbtPixelProcessing pixelProcessor = new LgbtPixelProcessing(rowCounter, columnCounter, source, k, localRadius, globalRadius, globalThreshold);
             *      image.Data[columnCounter, rowCounter] = pixelProcessor.CalculatedPixelValue();
             *  }
             * }
             * );
             */

            var syncTask = new Task(() =>
            {
                Parallel.For(0, image.Rows, j =>
                {
                    for (int i = 0; i < image.Cols; i++)
                    {
                        //LgbtPixelProcessing pixelProcessor = new LgbtPixelProcessing(rowCounter, columnCounter, image, k, localRadius, globalRadius, globalThreshold);
                        //image.Data[columnCounter, rowCounter] = pixelProcessor.CalculatedPixelValue();
                        LgbtPixelProcessing pixelProcessor = new LgbtPixelProcessing(j, i, source, _k, _localRadius, _globalRadius, _globalThreshold);
                        image.Data[j, i] = pixelProcessor.CalculatedPixelValue();
                    }
                });
            });

            syncTask.RunSynchronously();

            return(image);
        }
 public UltrasoundModA(SimpleGrayImage image, int topIndention, int bottomIndention)
 {
     Image       = image;
     _topLine    = topIndention;
     _bottomLine = image.Rows - bottomIndention;
 }
Пример #14
0
 public Elastogram(SimpleGrayImage image)
 {
     Image = image;
 }