public static ImageConditionAndDataRepresentingForm RepresentDataFromDenseMatrix(object dmToRepresent, string dataName = "", bool withFixedScaleMargins = false, bool withSymmetricColorScheme = false, double minScaleValue = 0.0d, double maxScaleValue = 1.0d, bool showTheWindow = true)
        {
            imageConditionAndData dataRepresentingImgData = new imageConditionAndData(dmToRepresent, null);

            if (withSymmetricColorScheme)
            {
                dataRepresentingImgData.currentColorScheme = new ColorScheme("", true);
            }
            else
            {
                dataRepresentingImgData.currentColorScheme = new ColorScheme("");
            }
            dataRepresentingImgData.currentColorSchemeRuler = new ColorSchemeRuler(dataRepresentingImgData);
            if (!withFixedScaleMargins)
            {
                dataRepresentingImgData.currentColorSchemeRuler.IsMarginsFixed = false;
                dataRepresentingImgData.UpdateColorSchemeRuler();
            }
            else
            {
                dataRepresentingImgData.currentColorSchemeRuler.IsMarginsFixed = true;
                dataRepresentingImgData.currentColorSchemeRuler.minValue       = minScaleValue;
                dataRepresentingImgData.currentColorSchemeRuler.maxValue       = maxScaleValue;
                dataRepresentingImgData.UpdateColorSchemeRuler();
            }
            ImageConditionAndDataRepresentingForm dmTestReversedRepresentingForm = new ImageConditionAndDataRepresentingForm(dataRepresentingImgData, dataName);

            if (showTheWindow)
            {
                dmTestReversedRepresentingForm.Show();
            }
            return(dmTestReversedRepresentingForm);
        }
示例#2
0
        private void btnChangeColorScheme_Click(object sender, EventArgs e)
        {
            imgData = imgData.Copy();



            //TextBox currFilenameTextbox = tbColorSchemePath1;
            //PictureBox pbCurrentColorScheme = pbRes1Scale;



            OpenFileDialog opFD = new OpenFileDialog();

            opFD.Filter           = "RGB files (*.rgb)|*.rgb|All files (*.*)|*.*";
            opFD.InitialDirectory = Directory.GetCurrentDirectory();
            opFD.Multiselect      = false;
            DialogResult dialogRes = opFD.ShowDialog();

            if (dialogRes == DialogResult.OK)
            {
                String   filename = opFD.FileName;
                FileInfo fInfo    = new FileInfo(filename);
                //if (fInfo.DirectoryName == Directory.GetCurrentDirectory()) ThreadSafeOperations.SetTextTB(currFilenameTextbox, fInfo.Name, false);
                //else ThreadSafeOperations.SetTextTB(currFilenameTextbox, fInfo.FullName, false);

                imgData.currentColorScheme = new ColorScheme(fInfo.FullName);
                imgData.UpdateColorSchemeRuler();

                RaisePaintEvent(null, null);
            }
        }
示例#3
0
        private void pbRes_MouseUp(object sender, MouseEventArgs e)
        {
            // ReSharper disable InconsistentNaming
            imageConditionAndData currentICD = null;
            // ReSharper restore InconsistentNaming
            Type theSenderDataType = typeof(imageConditionAndData);



            if (e.Button == MouseButtons.Left && sender.Equals(meLeftButtonDownSender))
            {
                PictureBoxSelection pbSelection = null;

                if (sender == pbRes)
                {
                    currentICD        = imgData;
                    theSenderDataType = imgData.GetType();
                }
                else if (sender == pbScale)
                {
                    currentICD        = imgData;
                    theSenderDataType = imgData.currentColorSchemeRuler.GetType();
                }


                //если уже есть selection у этого объекта, а это выделение пусто - проверить, было ли оно внутри
                //если было внутри - значит, был клик или даблклик внутри выделения - не обрабатывать здесь
                if (theSenderDataType == typeof(imageConditionAndData))
                {
                    pbSelection = new PictureBoxSelection(sender, meLeftButtonDownArgs.Location, e.Location, currentICD);
                    if ((pbSelection.IsEmptySelection) && (currentICD.Selection != null))
                    {
                        if (currentICD.Selection.CheckIfDoubleclickedinsideSelection(sender, e, currentICD))
                        {
                            return;
                        }
                    }
                    currentICD.Selection = pbSelection;
                }
                else if (theSenderDataType == typeof(ColorSchemeRuler))
                {
                    pbSelection = new PictureBoxSelection(sender, meLeftButtonDownArgs.Location, e.Location, currentICD.currentColorSchemeRuler);
                    currentICD.currentColorSchemeRuler.Selection = pbSelection;
                }


                HighlightLinkedSelection(pbSelection);
                RaisePaintEvent(null, null);

                if ((theSenderDataType == typeof(ColorSchemeRuler)) && (imgData.HighlightMask != null))
                {
                    string testToShow = "significant area: " + imgData.maskImageBinary.CountNonzero()[0] + Environment.NewLine;
                    testToShow += "highlighted area: " + imgData.highlightedArea + Environment.NewLine;
                    testToShow += "highlighted area relative: " + (imgData.highlightedArea / (double)imgData.maskImageBinary.CountNonzero()[0]).ToString("e") + Environment.NewLine;
                    ThreadSafeOperations.SetTextTB(tbStats, testToShow, true);
                }
            }
        }
 /// <summary>
 /// DEPRECATED - use ColorSchemeRuler(imageConditionAndData imgData) instead
 /// </summary>
 /// <param name="currentColorScheme">The current color scheme.</param>
 /// <param name="inMinValue">The minimum data value.</param>
 /// <param name="inMaxValue">The maximum data value.</param>
 public ColorSchemeRuler(ColorScheme currentColorScheme, double inMinValue = -255.0d, double inMaxValue = 255.0d)
 {
     minValue            = inMinValue;
     maxValue            = inMaxValue;
     colorScheme         = currentColorScheme;
     markerPositionValue = inMaxValue;
     selection           = null;
     imgToRule           = null;
     isMarginsFixed      = true;
 }
示例#5
0
        public imageConditionAndData Copy()
        {
            imageConditionAndData retImageData = new imageConditionAndData(dmSourceData, maskImageBinary);

            retImageData.currentColorScheme                = currentColorScheme;
            retImageData.currentColorSchemeRuler           = currentColorSchemeRuler.Copy();
            retImageData.currentColorSchemeRuler.imgToRule = retImageData;
            retImageData.UpdateColorSchemeRuler();
            return(retImageData);
        }
 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;
 }
示例#7
0
        public ImageConditionAndDataRepresentingForm(imageConditionAndData imageData, string dataName = "")
        {
            imgData = imageData;

            InitializeComponent();

            if (dataName != "")
            {
                this.Text     = dataName;
                lblTitle.Text = dataName;
            }
        }
示例#8
0
        private void ConstructCurrHeatMapData()
        {
            currHeatMapData = new imageConditionAndData(dmDensityMesh, null);
            currHeatMapData.currentColorScheme = new ColorScheme("");
            currHeatMapData.currentColorScheme.colorsArray[0] = new Emgu.CV.Structure.Bgr(Color.White);
            currHeatMapData.currentColorSchemeRuler           = new ColorSchemeRuler(currHeatMapData.currentColorScheme);
            currHeatMapData.UpdateColorSchemeRuler();
            currHeatMapData.currentColorSchemeRuler.IsMarginsFixed = false;
            currHeatMapData.UpdateColorSchemeRuler();

            if (lPtdMarks.Count > 0)
            {
                UpdateHeatMapDataMarks();
            }
        }
示例#9
0
        private void pbRes_MouseMove(object sender, MouseEventArgs e)
        {
            imageConditionAndData currentImgData = null;

            if (sender == pbRes)
            {
                currentImgData = imgData;
            }
            PointD origDataPointPosition = new PointD();
            double clickedValue          = currentImgData.GetValueByClickEvent((PictureBox)sender, e, out origDataPointPosition);
            PointD thePointD             = currentImgData.getDataPositionByClickEvent((PictureBox)sender, e);
            Point  thePoint    = new Point(Convert.ToInt32(thePointD.X), Convert.ToInt32(thePointD.Y));
            string tooltipText = "position: " + thePoint + Environment.NewLine + ServiceTools.DoubleValueRepresentingString(clickedValue);

            ShowToolTip(e, tooltipText, sender);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorSchemeRuler"/> class using the imgData
 /// </summary>
 /// <param name="imgData">The image data and condition.</param>
 public ColorSchemeRuler(imageConditionAndData imgData)
 {
     minValue = imgData.dataMinValue();
     maxValue = imgData.dataMaxValue();
     if (imgData.currentColorScheme.isColorSchemeSymmetric)
     {
         minValue = -Math.Max(Math.Abs(minValue), Math.Abs(maxValue));
         maxValue = Math.Max(Math.Abs(minValue), Math.Abs(maxValue));
     }
     colorScheme         = imgData.currentColorScheme;
     markerPositionValue = maxValue;
     selection           = null;
     imgToRule           = imgData;
     //isMarginsFixed = imgData.isColorSchemeMarginsFixed;
     isMarginsFixed = false;
 }
示例#11
0
        /// <summary>
        /// Constructs  the image from selection.
        /// </summary>
        /// <param name="theSelection">The selection.</param>
        /// <returns>imageConditionAndData.</returns>
        public imageConditionAndData SelectedImageData(PictureBoxSelection theSelection = null)
        {
            if ((theSelection == null) && (selection != null))
            {
                theSelection = selection;
            }
            if (theSelection == null)
            {
                return(this);
            }

            Rectangle   theSelectionRectangle = (Rectangle)theSelection.SelectionRectReal;
            DenseMatrix subMatrix             = (DenseMatrix)dmSourceData.SubMatrix(
                theSelectionRectangle.Location.Y,
                theSelectionRectangle.Height,
                theSelectionRectangle.Location.X,
                theSelectionRectangle.Width);
            Image <Gray, Byte> img = ImageProcessing.grayscaleImageFromDenseMatrix(subMatrix);

            DenseMatrix maskMatrix = ImageProcessing.DenseMatrixFromImage(maskImageBinary);

            maskMatrix = (DenseMatrix)maskMatrix.SubMatrix(
                theSelectionRectangle.Location.Y,
                theSelectionRectangle.Height,
                theSelectionRectangle.Location.X,
                theSelectionRectangle.Width);
            //Image<Gray, Byte> maskSubImageBinary = maskImageBinary.GetSubRect(theSelectionRectangle);
            Image <Gray, Byte> maskSubImageBinary = ImageProcessing.grayscaleImageFromDenseMatrixWithFixedValuesBounds(maskMatrix, 0.0d, 1.0d);//  maskImageBinary.GetSubRect(theSelectionRectangle);

            maskSubImageBinary = maskSubImageBinary / 255;

            //Image<Gray, double> tmpHighlightingImage = img.CopyBlank();
            //tmpHighlightingImage.Draw((Rectangle)theSelection.SelectionRectReal, new Gray(255), -1);
            //img = img.AddWeighted(tmpHighlightingImage, 1.0, 0.15, 0.0);
            //img.Draw((Rectangle)theSelection.SelectionRectReal, new Gray(255), 1);
            //ImageProcessing imgPr = new ImageProcessing(img.Bitmap, false);
            //imgPr.significantMaskImageBinary = maskSubImageBinary;
            //imgPr.significantMaskImage = maskSubImageBinary*255;
            imageConditionAndData retImageData = new imageConditionAndData(subMatrix, maskSubImageBinary);

            retImageData.currentColorScheme                     = currentColorScheme;
            retImageData.currentColorSchemeRuler                = new ColorSchemeRuler(currentColorSchemeRuler);
            retImageData.currentColorSchemeRuler.imgToRule      = retImageData;
            retImageData.currentColorSchemeRuler.IsMarginsFixed = false;
            //retImageData.UpdateColorSchemeRuler();
            return(retImageData);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ColorSchemeRuler"/> class.
        /// With the forced maximum and minimum values
        /// </summary>
        /// <param name="imgData">The image data and condition.</param>
        /// <param name="minValueIn">The forced minimum value.</param>
        /// <param name="maxValueIn">The forced maximum value.</param>
        public ColorSchemeRuler(imageConditionAndData imgData, double minValueIn, double maxValueIn)
        {
            minValue = minValueIn;
            if ((!double.IsNaN(imgData.DmSourceData.Values.Min())) && (minValue >= imgData.DmSourceData.Values.Min()))
            {
                minValue = imgData.DmSourceData.Values.Min();
            }

            maxValue = maxValueIn;
            if ((!double.IsNaN(imgData.DmSourceData.Values.Max())) && (maxValue <= imgData.DmSourceData.Values.Max()))
            {
                maxValue = imgData.DmSourceData.Values.Max();
            }

            colorScheme         = imgData.currentColorScheme;
            markerPositionValue = maxValue;
            selection           = null;
            imgToRule           = imgData;
            //isMarginsFixed = imgData.isColorSchemeMarginsFixed;
            isMarginsFixed = true;
        }
        public void makeHihghlightMask()
        {
            if (imgToRule.Selection == null)
            {
                return;
            }

            imageConditionAndData tmpImgData = imgToRule.SelectedImageData();
            double filterMaxValue            = tmpImgData.DmSourceData.Values.Max();
            double filterMinValue            = tmpImgData.DmSourceData.Values.Min();

            selection = null;


            DenseMatrix dmHighlightDenseMatrix = DenseMatrix.Create(currentDimY, currentDimX, new Func <int, int, double>
                                                                    (
                                                                        (y, x) =>
            {
                double curValue = (double)y;
                curValue        = 1.0d - (1.0d + curValue) / (double)currentDimY;
                curValue        = minValue + curValue * (maxValue - minValue);
                if ((curValue >= filterMinValue) && (curValue <= filterMaxValue))
                {
                    return(255.0d);
                }
                else
                {
                    return(100.0d);
                }
            }
                                                                    ));
            Image <Gray, Byte> highlightImage = ImageProcessing.grayscaleImageFromDenseMatrixWithFixedValuesBounds(dmHighlightDenseMatrix, 0.0d, 255.0d);


            HighlightMask         = highlightImage.Convert <Gray, double>();
            HighlightMaskRelative = HighlightMask / 255.0d;
            //ImageProcessing.grayscaleImageFromDenseMatrixWithFixedValuesBounds(tmpDM, 0.0d, 255.0d).Convert<Gray, double>();
            //HighlightMask = HighlightMask / 255.0d;
        }