Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="imageConditionAndData"/> class.
        /// note: grayscaled, with fixed grayscale ruler 0.0d-255.0d
        /// </summary>
        /// <param name="imgPr">The img pr.</param>
        /// <param name="channelNum">The channel number.</param>
        public imageConditionAndData(ImageProcessing imgPr, int channelNum)
        {
            maskImageBinary      = imgPr.significantMaskImageBinary.Copy();
            isImageGrayscaled    = true;
            sourceImageGrayscale = imgPr.getMaskedImageChannelImage(channelNum);
            sourceImageBgr       = null;

            thresholdingUsageTop = false;
            thresholdingUsageBtm = true;
            thresholdingValue    = 255;

            dmSourceData = ImageProcessing.DenseMatrixFromImage(sourceImageGrayscale);


            currentColorScheme      = new ColorScheme("");
            currentColorSchemeRuler = new ColorSchemeRuler(this, dataMinValue(), dataMaxValue());
            selection = null;


            //makeThresholdedDataImage();
            dataHasBeenModified = true;

            HighlightMask   = null;
            highlightedArea = 0.0d;
        }
Пример #2
0
 public void setGrayscaleCalculatedColorScheme()
 {
     currentColorScheme = new ColorScheme(true);
     //currentColorSchemeRuler = new ColorSchemeRuler(currentColorScheme, dataMinValue(), dataMaxValue());
     currentColorSchemeRuler = new ColorSchemeRuler(this, 0.0d, 255.0d);
     dataHasBeenModified     = true;
 }
Пример #3
0
        //attention!
        //int channelNum - zero-based channel number with B-G-R scheme
        public imageConditionAndData(Bitmap coloredBitmap, int channelNum)
        {
            ImageProcessing imgPr = new ImageProcessing(coloredBitmap, true);

            maskImageBinary = imgPr.significantMaskImageBinary;
            //imgPr.Dispose();
            isImageGrayscaled    = true;
            sourceImageGrayscale = new Image <Bgr, Byte>(coloredBitmap)[channelNum];
            sourceImageBgr       = null;
            sourceImageGrayscale = sourceImageGrayscale.Mul(maskImageBinary);

            thresholdingUsageTop = false;
            thresholdingUsageBtm = true;
            thresholdingValue    = 255;

            //Image<Gray, Byte> thresholdedImage = imgPr.getMaskedImageChannelBitmapThresholded(channelNum, thresholdingValue, thresholdingUsageTop, thresholdingUsageBtm);
            dmSourceData = ImageProcessing.DenseMatrixFromImage(sourceImageGrayscale);

            currentColorScheme      = new ColorScheme("");
            currentColorSchemeRuler = new ColorSchemeRuler(this, dataMinValue(), dataMaxValue());
            selection = null;

            //makeThresholdedDataImage();
            dataHasBeenModified = true;

            HighlightMask   = null;
            highlightedArea = 0.0d;
        }
 public ColorSchemeRuler(ColorSchemeRuler sourceRuler)
 {
     minValue            = sourceRuler.minValue;
     maxValue            = sourceRuler.maxValue;
     colorScheme         = sourceRuler.colorScheme;
     markerPositionValue = maxValue;
     selection           = null;
     imgToRule           = null;
     //isMarginsFixed = imgData.isColorSchemeMarginsFixed;
     isMarginsFixed = sourceRuler.isMarginsFixed;
 }
Пример #5
0
 /// <summary>
 /// Updates the color scheme ruler for the class instance
 /// taking into account the fact whether the ruler has fixed values margins or not
 /// </summary>
 public void UpdateColorSchemeRuler()
 {
     if (currentColorSchemeRuler.IsMarginsFixed)
     {
         currentColorSchemeRuler = new ColorSchemeRuler(this, currentColorSchemeRuler.minValue, currentColorSchemeRuler.maxValue);
     }
     else
     {
         currentColorSchemeRuler = new ColorSchemeRuler(this);
     }
     dataHasBeenModified = true;
 }
Пример #6
0
        private void chbRes1DynamicScale_CheckedChanged(object sender, EventArgs e)
        {
            ColorSchemeRuler currentResultRuler = null;

            if (sender == chbRes1DynamicScale)
            {
                currentResultRuler = imgData.currentColorSchemeRuler;
            }


            currentResultRuler.IsMarginsFixed = !((CheckBox)sender).Checked;

            RaisePaintEvent(null, null);
        }
Пример #7
0
        private void pbScale_MouseMove(object sender, MouseEventArgs e)
        {
            ColorSchemeRuler currentRuler = null;

            if (sender == pbScale)
            {
                currentRuler = imgData.currentColorSchemeRuler;
            }


            double clickedValue = currentRuler.GetValueByClickEvent((PictureBox)sender, e);

            clickedValue = Math.Round(clickedValue, 2);

            ShowToolTip(e, clickedValue.ToString(), sender);
        }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="imageConditionAndData"/> class.
        /// note: with the fixed ruler bounds
        /// </summary>
        /// <param name="imgPr">The image processing object contains image data and some processing templates.</param>
        public imageConditionAndData(ImageProcessing imgPr)
        {
            maskImageBinary      = imgPr.significantMaskImageBinary.Copy();
            isImageGrayscaled    = false;
            sourceImageBgr       = imgPr.tmpImage.Copy();
            sourceImageGrayscale = null;

            thresholdingUsageTop = false;
            thresholdingUsageBtm = true;
            thresholdingValue    = 255;

            dmSourceData = ImageProcessing.DenseMatrixFromImage(sourceImageBgr.Convert <Gray, Byte>());

            currentColorScheme = new ColorScheme("");
            //currentColorSchemeRuler = new ColorSchemeRuler(currentColorScheme, dataMinValue(), dataMaxValue());
            currentColorSchemeRuler = new ColorSchemeRuler(this, -255.0d, 255.0d);
            selection = null;

            //makeThresholdedDataImage();
            dataHasBeenModified = true;

            HighlightMask   = null;
            highlightedArea = 0.0d;
        }
        //private MouseEventArgs _eDown, _eUp;


        public PictureBoxSelection(object sender, Point pDown, Point pUp, object imgData)
        {
            int mouseEventMaxWidthPix  = ((PictureBox)sender).Image.Width;
            int mouseEventMaxHeightPix = ((PictureBox)sender).Image.Height;

            usedImageData = imgData;
            _pDown        = pDown;
            _pUp          = pUp;

            if (_pDown.X < 0)
            {
                _pDown.X = 0;
            }
            else if (_pDown.X > mouseEventMaxWidthPix)
            {
                _pDown.X = mouseEventMaxWidthPix;
            }
            //else if ((_pDown.X % 4 > 2) && (_pDown.X + 4 - _pDown.X % 4 < mouseEventMaxWidthPix)) _pDown.X += 4 - _pDown.X%4;
            //else _pDown.X -= _pDown.X % 4;

            if (_pDown.Y < 0)
            {
                _pDown.Y = 0;
            }
            else if (_pDown.Y > mouseEventMaxHeightPix)
            {
                _pDown.Y = mouseEventMaxHeightPix;
            }
            //else if ((_pDown.Y % 4 > 2) && (_pDown.Y + 4 - _pDown.Y % 4 < mouseEventMaxHeightPix)) _pDown.Y += 4 - _pDown.Y % 4;
            //else _pDown.Y -= _pDown.Y % 4;

            if (_pUp.X < 0)
            {
                _pUp.X = 0;
            }
            else if (_pUp.X > mouseEventMaxWidthPix)
            {
                _pUp.X = mouseEventMaxWidthPix;
            }
            //else if ((_pUp.X % 4 > 2) && (_pUp.X + 4 - _pUp.X % 4 < mouseEventMaxWidthPix)) _pUp.X += 4 - _pUp.X % 4;
            //else _pUp.X -= _pUp.X % 4;

            if (_pUp.Y < 0)
            {
                _pUp.Y = 0;
            }
            else if (_pUp.Y > mouseEventMaxHeightPix)
            {
                _pUp.Y = mouseEventMaxHeightPix;
            }
            //else if ((_pUp.Y % 4 > 2) && (_pUp.Y + 4 - _pUp.Y % 4 < mouseEventMaxHeightPix)) _pUp.Y += 4 - _pUp.Y % 4;
            //else _pUp.Y -= _pUp.Y % 4;


            underlyingPictureBox = (PictureBox)sender;
            if (usedImageData.GetType().Equals(typeof(imageConditionAndData)))
            {
                k                 = (double)(((imageConditionAndData)usedImageData).dataRepresentingImageColored().Width) / (double)(underlyingPictureBox.Image.Width);
                selectionRect     = new Rectangle(Math.Min(_pDown.X, _pUp.X), Math.Min(_pDown.Y, _pUp.Y), Math.Max(_pDown.X, _pUp.X) - Math.Min(_pDown.X, _pUp.X), Math.Max(_pDown.Y, _pUp.Y) - Math.Min(_pDown.Y, _pUp.Y));
                selectionRectReal = new Rectangle(
                    Convert.ToInt32(Math.Round((double)selectionRect.Location.X * k, 0)),
                    Convert.ToInt32(Math.Round((double)selectionRect.Location.Y * k, 0)),
                    Convert.ToInt32(Math.Round((double)selectionRect.Width * k, 0)),
                    Convert.ToInt32(Math.Round((double)selectionRect.Height * k, 0)));
                if (selectionRectReal.Width % 4 != 0)
                {
                    selectionRectReal.Width += 4 - (selectionRectReal.Width % 4);
                }
                if (selectionRectReal.Height % 4 != 0)
                {
                    selectionRectReal.Height += 4 - (selectionRectReal.Height % 4);
                }
                if (selectionRectReal.Right > (int)ServiceTools.getPropValue(usedImageData, "Width"))
                {
                    selectionRectReal.Location = new Point(selectionRectReal.Location.X - (selectionRectReal.Right - (int)ServiceTools.getPropValue(usedImageData, "Width")), selectionRectReal.Location.Y);
                }
                if (selectionRectReal.Bottom > (int)ServiceTools.getPropValue(usedImageData, "Height"))
                {
                    selectionRectReal.Location = new Point(selectionRectReal.Location.X, selectionRectReal.Location.Y - (selectionRectReal.Bottom - (int)ServiceTools.getPropValue(usedImageData, "Height")));
                }
            }
            else if (usedImageData.GetType().Equals(typeof(ColorSchemeRuler)))
            {
                ColorSchemeRuler tmpRuler     = (ColorSchemeRuler)usedImageData;
                Point            tmpEventArgs = (_pDown.Y > _pUp.Y) ? (_pUp) : (_pDown);
                k                        = (double)(tmpRuler.maxValue - tmpRuler.minValue) / (double)(underlyingPictureBox.Image.Height);
                selectionRect            = new Rectangle(0, Math.Min(_pDown.Y, _pUp.Y), ((PictureBox)sender).Width, Math.Max(_pDown.Y, _pUp.Y) - Math.Min(_pDown.Y, _pUp.Y));
                selectionRectSchemeRuler = new RectangleF(
                    0.0f,
                    (float)(tmpRuler.GetValueByClickEvent((PictureBox)sender, tmpEventArgs)),
                    (float)((PictureBox)sender).Width,
                    (float)(selectionRect.Height * k)
                    );
            }
        }