public void ClearLog(int maxLinesCount = 2048)
 {
     if (textBox1.Lines.Count() >= maxLinesCount)
     {
         ThreadSafeOperations.SetTextTB(textBox1, "", false);
     }
 }
示例#2
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);
                }
            }
        }
        public void SwapLog(string filename)
        {
            if (!ServiceTools.CheckIfDirectoryExists(filename))
            {
                return;
            }

            ServiceTools.logToTextFile(filename, textBox1.Text, false);

            ThreadSafeOperations.SetTextTB(textBox1, "", false);
        }
        public void DetectConnected()
        {
            var classificator = new SkyCloudClassification(processingImage, defaultProperties);

            classificator.Classify();
            DenseMatrix        dmSkyIndexDataBinary  = classificator.dmSkyIndexDataBinary();
            Image <Gray, Byte> imgSkyIndexDataBinary = ImageProcessing.grayscaleImageFromDenseMatrixWithFixedValuesBounds(dmSkyIndexDataBinary, 0.0d, 1.0d, true);

            imgSkyIndexDataBinary = imgSkyIndexDataBinary.Mul(classificator.maskImage);
            Image <Bgr, Byte> previewImage = imgSkyIndexDataBinary.CopyBlank().Convert <Bgr, Byte>();


            // Contour<Point> contoursDetected = imgSkyIndexDataBinary.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_LIST);

            #region // EmguCV 3.0
            //VectorOfVectorOfPoint contoursDetected = new VectorOfVectorOfPoint();
            //CvInvoke.FindContours(imgSkyIndexDataBinary, contoursDetected, null, Emgu.CV.CvEnum.RetrType.List,
            //    Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);
            //contoursArray = new List<VectorOfPoint>();
            //int count = contoursDetected.Size;
            //var colorGen = new RandomPastelColorGenerator();
            //for (int i = 0; i < count; i++)
            //{
            //    Color currentColor = colorGen.GetNext();
            //    var currentColorBgr = new Bgr(currentColor.B, currentColor.G, currentColor.R);
            //    using (VectorOfPoint currContour = contoursDetected[i])
            //    {
            //        contoursArray.Add(currContour);
            //        previewImage.Draw(currContour.ToArray(), currentColorBgr, -1); //.Draw(currContour, currentColorBgr, -1);
            //    }
            //}
            #endregion // EmguCV 3.0


            List <Contour <Point> >    contoursDetected = imgSkyIndexDataBinary.DetectContours();
            RandomPastelColorGenerator colorGen         = new RandomPastelColorGenerator();
            foreach (Contour <Point> currContour in contoursDetected)
            {
                Color currentColor    = colorGen.GetNext();
                Bgr   currentColorBgr = new Bgr(currentColor.B, currentColor.G, currentColor.R);
                previewImage.Draw(currContour, currentColorBgr, -1);
            }


            ThreadSafeOperations.SetTextTB(tbLog, "Количество выделенных объектов: " + contoursArray.Count + Environment.NewLine, true);


            //ShowImageForm ImgShow = new ShowImageForm(localPreviewBitmap, ParentForm, this);
            var imgShow = new SimpleShowImageForm(previewImage);
            imgShow.Show();
        }
        void bgwQueueOutputWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker thisWorker = sender as BackgroundWorker;

            while (true)
            {
                if (thisWorker.CancellationPending)
                {
                    break;
                }

                try
                {
                    if (cqLinesToLog.Count > 0)
                    {
                        while (cqLinesToLog.Count > 0)
                        {
                            LinesToDisplay currLine = new LinesToDisplay();
                            while (!cqLinesToLog.TryDequeue(out currLine))
                            {
                                Application.DoEvents();
                                Thread.Sleep(0);
                            }
                            ThreadSafeOperations.SetTextTB(textBox1, currLine.textLine, currLine.appendMode);
                            Application.DoEvents();
                            Thread.Sleep(0);
                        }
                    }
                    else
                    {
                        Application.DoEvents();
                        Thread.Sleep(0);
                        continue;
                    }
                }
                catch (Exception)
                {
                    Application.DoEvents();
                    Thread.Sleep(0);
                    continue;
                }
            }
        }
        public static void AddDataMatrixToFile(DenseMatrix dmData, string fileName, TextBox tbLog,
                                               bool absolutePath = false, string varName = "dataMatrix")
        {
            string baseDir          = "G:\\_gulevlab\\SkyIndexAnalyzerSolo_appData\\_dataDirectory\\";
            string connectionString = "msds:nc?file=";

            if (absolutePath)
            {
                if (!ServiceTools.CheckIfDirectoryExists(fileName))
                {
                    return;
                }
                connectionString += fileName;
            }
            else
            {
                if (!ServiceTools.CheckIfDirectoryExists(baseDir + fileName))
                {
                    return;
                }
                connectionString += baseDir + fileName;
            }

            NetCDFDataSet ds = null;

            try
            {
                ds = new NetCDFDataSet(connectionString, ResourceOpenMode.OpenOrCreate);
            }
            catch (Exception ex)
            {
                if (tbLog != null)
                {
                    ThreadSafeOperations.SetTextTB(tbLog, "Не получилось :( " + Environment.NewLine + ex.Message, true);
                }
                else
                {
                    throw ex;
                }
            }


            Variable <double> thDataVar;

            if (!ds.Variables.Contains(varName))
            {
                thDataVar = ds.AddVariable <double>(varName, dmData.ToArray(), "y", "x");
            }
            else
            {
                thDataVar = (Variable <double>)ds.Variables[varName];
                thDataVar.Append(dmData.ToArray());
            }


            try
            {
                ds.TryCommit();
            }
            catch (Exception ex)
            {
                if (tbLog != null)
                {
                    ThreadSafeOperations.SetTextTB(tbLog, "Не получилось :( " + Environment.NewLine + ex.Message, true);
                }
                else
                {
                    throw ex;
                }
            }

            ds.Dispose();
        }
        public void Represent()
        {
            if (histToRepresent.IsEmpty())
            {
                return;
            }

            ThreadSafeOperations.SetTextTB(tbStats, "", false);

            double maxHistProbValue = histToRepresent.dvProbDens.Values.Max();
            double ySpaceGap        = 0.2d * maxHistProbValue;

            overallProbMax = maxHistProbValue + ySpaceGap;

            double maxHistValues = histToRepresent.dvData.Values.Max();
            double minHistValues = histToRepresent.dvData.Values.Min();

            double xSpaceGap = 0.2d * (maxHistValues - minHistValues);

            xSpaceMin = ((minHistValues - xSpaceGap) < xSpaceMin) ? (minHistValues - xSpaceGap) : (xSpaceMin);
            xSpaceMax = ((maxHistValues + xSpaceGap) > xSpaceMax) ? (maxHistValues + xSpaceGap) : (xSpaceMax);

            pictureWidth    = pbHistRepresentation.Width;
            pictureHeight   = pbHistRepresentation.Height;
            serviceSpaceGap = Convert.ToInt32(0.05d * Math.Min(pictureHeight, pictureWidth));
            theImage        = new Image <Bgr, Byte>(pictureWidth, pictureHeight, new Bgr(255, 255, 255));


            List <Point> rulerVertices = new List <Point>();

            rulerVertices.Add(new Point(serviceSpaceGap, pictureHeight - serviceSpaceGap));
            rulerVertices.Add(new Point(pictureWidth - serviceSpaceGap, pictureHeight - serviceSpaceGap));
            rulerVertices.Add(new Point(pictureWidth - serviceSpaceGap, serviceSpaceGap));
            rulerVertices.Add(new Point(serviceSpaceGap, serviceSpaceGap));
            theImage.DrawPolyline(rulerVertices.ToArray(), true, colorBlack, 2);

            koeffY = ((double)pictureHeight - 2.0d * (double)serviceSpaceGap) / (overallProbMax);
            koeffX = ((double)pictureWidth - 2.0d * (double)serviceSpaceGap) / (xSpaceMax - xSpaceMin);



            #region Прописываем текстовые маркеры

            double dMarkersCount = (double)(pictureHeight - (2 * serviceSpaceGap)) / 30.0d;
            dMarkersCount = (dMarkersCount > 10.0d) ? (10.0d) : (dMarkersCount);
            double dRulerValueGap      = (overallProbMax) / (double)dMarkersCount;
            int    deciGap             = Convert.ToInt32(Math.Truncate(Math.Log(dRulerValueGap, 2.0d)));
            double rulerValueGap       = Math.Pow(2.0, (double)deciGap);
            double lowerMarkerValue    = 0.0d;
            double currentMarkerValue  = lowerMarkerValue;
            double nextYPositionDouble = (1.0d - ((currentMarkerValue) / overallProbMax)) * (double)(pictureHeight - 2 * serviceSpaceGap) + serviceSpaceGap;
            while (nextYPositionDouble > serviceSpaceGap)
            {
                double        yPositionDouble = (1.0d - ((currentMarkerValue) / overallProbMax)) * (double)(pictureHeight - 2 * serviceSpaceGap) + serviceSpaceGap;
                int           yPosition       = Convert.ToInt32(Math.Round(yPositionDouble));
                LineSegment2D theLine         = new LineSegment2D(new Point(serviceSpaceGap, yPosition), new Point(serviceSpaceGap - 5, yPosition));
                Bgr           markerColor     = colorBlack;
                theImage.Draw(theLine, markerColor, 2);
                String message = Math.Round(currentMarkerValue, 2).ToString();
                theImage.Draw(message, ref theFont, new Point(2, yPosition), markerColor);
                // theImage.Draw(message, new Point(2, yPosition), FontFace.HersheyPlain, 1.0d, markerColor);
                currentMarkerValue += rulerValueGap;
                nextYPositionDouble = (1.0d - ((currentMarkerValue) / overallProbMax)) * (double)(pictureHeight - 2 * serviceSpaceGap) + serviceSpaceGap;
            }

            double dMarkersCountX = (double)(pictureWidth - (2 * serviceSpaceGap)) / 30.0d;
            dMarkersCountX = (dMarkersCountX > 10.0d) ? (10.0d) : (dMarkersCountX);
            double dRulerValueGapX   = (xSpaceMax - xSpaceMin) / (double)dMarkersCountX;
            int    deciGapX          = Convert.ToInt32(Math.Truncate(Math.Log(dRulerValueGapX, 2.0d)));
            double rulerValueGapX    = Math.Pow(2.0, (double)deciGapX);
            double lowerMarkerValueX = xSpaceMin - Math.IEEERemainder(xSpaceMin, rulerValueGapX);
            lowerMarkerValueX = (lowerMarkerValueX < xSpaceMin) ? (lowerMarkerValueX + rulerValueGapX) : (lowerMarkerValueX);
            double currentMarkerValueX = lowerMarkerValueX;
            double nextXPositionDouble = serviceSpaceGap + ((currentMarkerValueX - xSpaceMin) / (xSpaceMax - xSpaceMin)) * (double)(pictureWidth - 2 * serviceSpaceGap);
            while (nextXPositionDouble < pictureWidth - serviceSpaceGap)
            {
                double        xPositionDouble = serviceSpaceGap + ((currentMarkerValueX - xSpaceMin) / (xSpaceMax - xSpaceMin)) * (double)(pictureWidth - 2 * serviceSpaceGap);
                int           xPosition       = Convert.ToInt32(Math.Round(xPositionDouble));
                LineSegment2D theLine         = new LineSegment2D(new Point(xPosition, pictureHeight - serviceSpaceGap), new Point(xPosition, pictureHeight - serviceSpaceGap + 5));
                Bgr           markerColor     = colorBlack;
                theImage.Draw(theLine, markerColor, 2);
                String message = Math.Round(currentMarkerValueX, 2).ToString();
                theImage.Draw(message, ref theFont, new Point(xPosition, pictureHeight - 10), markerColor);
                // theImage.Draw(message, new Point(xPosition, pictureHeight - 10), FontFace.HersheyPlain, 1.0d, markerColor);
                currentMarkerValueX += rulerValueGapX;
                nextXPositionDouble  = serviceSpaceGap + ((currentMarkerValueX - xSpaceMin) / (xSpaceMax - xSpaceMin)) * (double)(pictureWidth - 2 * serviceSpaceGap);
            }

            #endregion Прописываем текстовые маркеры


            #region проставляем квантили, если надо

            if (cbShowQuantiles.Checked)
            {
                for (int i = 0; i < histToRepresent.quantilesList.Count; i++)
                {
                    double binCenter            = histToRepresent.quantilesList[i];
                    int    xCoordinateBinCenter = Convert.ToInt32(serviceSpaceGap + (binCenter - xSpaceMin) * koeffX);
                    Point  ptTop    = new Point(xCoordinateBinCenter, pictureHeight - serviceSpaceGap);
                    Point  ptBottom = new Point(xCoordinateBinCenter, serviceSpaceGap);
                    theImage.Draw(new LineSegment2D(ptTop, ptBottom), colorGreen, 2);
                }

                double medianCenter            = histToRepresent.Median;
                int    xCoordinateMedianCenter = Convert.ToInt32(serviceSpaceGap + (medianCenter - xSpaceMin) * koeffX);
                Point  ptMedianTop             = new Point(xCoordinateMedianCenter, pictureHeight - serviceSpaceGap);
                Point  ptMedianBottom          = new Point(xCoordinateMedianCenter, serviceSpaceGap);
                theImage.Draw(new LineSegment2D(ptMedianTop, ptMedianBottom), colorRed, 2);

                double perc5Center            = histToRepresent.Perc5;
                int    xCoordinateperc5Center = Convert.ToInt32(serviceSpaceGap + (perc5Center - xSpaceMin) * koeffX);
                Point  ptPerc5Top             = new Point(xCoordinateperc5Center, pictureHeight - serviceSpaceGap);
                Point  ptPerc5Bottom          = new Point(xCoordinateperc5Center, serviceSpaceGap);
                theImage.Draw(new LineSegment2D(ptPerc5Top, ptPerc5Bottom), colorRed, 2);
            }
            #endregion проставляем квантили, если надо


            if (rbtnShowAsBars.Checked)
            {
                double dBarWidth = (double)pictureWidth - 2.0d * (double)serviceSpaceGap;
                int    barsCount = histToRepresent.BinsCount;
                dBarWidth = dBarWidth / (double)barsCount;
                dBarWidth = dBarWidth / 3.0d;
                barWidth  = Convert.ToInt32(dBarWidth);
                barWidth  = (barWidth < 1) ? (1) : (barWidth);
                int barWidthHalfed = Convert.ToInt32(dBarWidth / 2.0d);
                barWidthHalfed = (barWidthHalfed < 1) ? (1) : (barWidthHalfed);


                for (int i = 0; i < histToRepresent.BinsCount; i++)
                {
                    double binCenter            = histToRepresent.dvbinsCenters[i];
                    double probDens             = histToRepresent.dvProbDens[i];
                    int    xCoordinateBinCenter = Convert.ToInt32(serviceSpaceGap + (binCenter - xSpaceMin) * koeffX);
                    int    yCoordinateTop       = Convert.ToInt32(pictureHeight - serviceSpaceGap - probDens * koeffY);
                    yCoordinateTop = (yCoordinateTop == pictureHeight - serviceSpaceGap)
                        ? (pictureHeight - serviceSpaceGap - 2)
                        : (yCoordinateTop);
                    Point ptUperLeft = new Point(xCoordinateBinCenter - barWidthHalfed, yCoordinateTop);
                    Size  barSize    = new Size(barWidth, pictureHeight - serviceSpaceGap - yCoordinateTop);

                    theImage.Draw(new Rectangle(ptUperLeft, barSize), new Bgr(histToRepresent.color), -1);
                }
            }
            else
            {
                for (int i = 0; i < histToRepresent.BinsCount; i++)
                {
                    double binCenter            = histToRepresent.dvbinsCenters[i];
                    double probDens             = histToRepresent.dvProbDens[i];
                    int    xCoordinateBinCenter = Convert.ToInt32(serviceSpaceGap + (binCenter - xSpaceMin) * koeffX);
                    int    yCoordinateTop       = Convert.ToInt32(pictureHeight - serviceSpaceGap - probDens * koeffY);
                    PointF ptToShow             = new PointF((float)xCoordinateBinCenter, (float)yCoordinateTop);

                    theImage.Draw(new CircleF(ptToShow, 4), new Bgr(histToRepresent.color), -1);
                }
            }

            string str2Show = "[" + histToRepresent.description + "]" + Environment.NewLine;
            //str2Show += "color: " + histToRepresent.color.ToString() + Environment.NewLine;
            str2Show += "perc5 = " + histToRepresent.Perc5.ToString("e") + Environment.NewLine;
            str2Show += "median = " + histToRepresent.Median.ToString("e") + Environment.NewLine;
            str2Show += "mean = " + histToRepresent.stats.Mean.ToString("e") + Environment.NewLine;
            str2Show += "stdDev = " + histToRepresent.stats.StandardDeviation.ToString("e") + Environment.NewLine;
            str2Show += "min value = " + histToRepresent.stats.Minimum.ToString("e") + Environment.NewLine;
            str2Show += "max value = " + histToRepresent.stats.Maximum.ToString("e") + Environment.NewLine;
            ThreadSafeOperations.SetTextTB(tbStats, str2Show, true);

            ThreadSafeOperations.UpdatePictureBox(pbHistRepresentation, theImage.Bitmap, false);
        }
        public void RPNeval(bool forceUsingDistributedMatrixes = false)
        {
            dmRes    = null;
            resValue = 0.0d;
            String input = exprString; //.Replace(" ", "");

            if (!forceUsingDistributedMatrixes)
            {
                if (dmR == null)
                {
                    dmR = ImageProcessing.DenseMatrixFromImage(imgR);
                }
                if (dmG == null)
                {
                    dmG = ImageProcessing.DenseMatrixFromImage(imgG);
                }
                if (dmB == null)
                {
                    dmB = ImageProcessing.DenseMatrixFromImage(imgB);
                }
                dmY = sRGBluminanceFrom_sRGB(dmR, dmG, dmB);
            }

            PostfixNotation rpn = new PostfixNotation();

            string[] converted2RPN = rpn.ConvertToPostfixNotation(input);

            Stack <ImageOperationalValue> stack = new Stack <ImageOperationalValue>();
            Queue <string> queue = new Queue <string>(converted2RPN);
            string         str   = queue.Dequeue();

            while (queue.Count >= 0)
            {
                if (!rpn.operators.Contains(str))
                {
                    pushImageToStackByColorChar(stack, str);
                    if (queue.Count > 0)
                    {
                        try
                        {
                            str = queue.Dequeue();
                        }
                        catch (Exception)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    ImageOperationalValue summ = null;
                    try
                    {
                        switch (str)
                        {
                        case "+":
                        {
                            ImageOperationalValue a = stack.Pop();
                            ImageOperationalValue b = stack.Pop();
                            summ = ImageOperationalValueAdd(a, b);        // b + a
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "-":
                        {
                            ImageOperationalValue a = stack.Pop();
                            ImageOperationalValue b = stack.Pop();
                            summ = ImageOperationalValueSubtract(a, b);        // b - a
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "*":
                        {
                            ImageOperationalValue a = stack.Pop();
                            ImageOperationalValue b = stack.Pop();
                            summ = ImageOperationalValueMult(a, b);        // b * a
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "/":
                        {
                            ImageOperationalValue a = stack.Pop();
                            ImageOperationalValue b = stack.Pop();
                            summ = ImageOperationalValueDivide(a, b);        // b / a
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "^":
                        {
                            double a = stack.Pop().dNumber;
                            ImageOperationalValue b = stack.Pop();
                            summ = ImageOperationalValuePow(b, a);        // b ^ a
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "grad":
                        {
                            ImageOperationalValue a = stack.Pop();
                            summ = ImageOperationalValueGrad(a);        // grad(a)
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "grad5p":
                        {
                            ImageOperationalValue a = stack.Pop();
                            summ = ImageOperationalValueGrad5p(a);        // grad 5-point(a)
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "ddx":
                        {
                            ImageOperationalValue a = stack.Pop();
                            summ = ImageOperationalValueDDX(a);        // d(a)/dx
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "ddy":
                        {
                            ImageOperationalValue a = stack.Pop();
                            summ = ImageOperationalValueDDY(a);        // d(a)/dy
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "sqrt":
                        {
                            ImageOperationalValue a = stack.Pop();
                            summ = ImageOperationalValueSqrt(a);        // grad(a)
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "mean":
                        {
                            ImageOperationalValue a = stack.Pop();
                            summ = ImageOperationalValueMean(a);        // mean(a)
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "stddev":
                        {
                            ImageOperationalValue a = stack.Pop();
                            summ = ImageOperationalValueSigm(a);        // mean(a)
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "abs":
                        {
                            ImageOperationalValue a = stack.Pop();
                            summ = ImageOperationalValueAbs(a);        // abs(a)
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "%":
                        {
                            double a = stack.Pop().dNumber;
                            ImageOperationalValue b = stack.Pop();
                            summ = ImageOperationalValueCut(b, a);        // b cut a - cuts "b" matrix elements using "a"*sigma limit of distribution. remember 3-sigma rule?
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        case "smoothcos":
                        {
                            double a = stack.Pop().dNumber;
                            ImageOperationalValue b = stack.Pop();
                            summ = ImageOperationalValueSmoothCos(b, a);        // b cut a - cuts "b" matrix elements using "a"-nodes spreading cos-based kernel
                            ServiceTools.FlushMemory(tbLog, "");
                            break;
                        }

                        default:
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        ThreadSafeOperations.SetTextTB(tbLog, ex.Message, true);
                    }
                    stack.Push(summ);
                    if (queue.Count > 0)
                    {
                        str = queue.Dequeue();
                    }
                    else
                    {
                        break;
                    }
                }
            }
            //return Convert.ToDecimal(stack.Pop());
            ImageOperationalValue theResult = stack.Pop();

            dmRes    = theResult.DmImageComponent;
            resValue = theResult.dNumber;
            lDMRes   = theResult.lDMOtherComponents;

            if (dmRes != null)
            {
                minValue = dmRes.Values.Min();
                maxValue = dmRes.Values.Max();
            }
            else
            {
                minValue = resValue;
                maxValue = resValue;
            }

            ThreadSafeOperations.SetTextTB(tbLog, Environment.NewLine + "min value: " + Math.Round(minValue, 2).ToString(), false);
            ThreadSafeOperations.SetTextTB(tbLog, "max value: " + Math.Round(maxValue, 2).ToString(), true);

            ServiceTools.FlushMemory(tbLog, "");
        }