private void btnContrastGraph_Click(object sender, EventArgs e)
        {
            if (OriginalImageMatrix != null)
            {
                int OriginalWidth = int.Parse(txtWidth.Text);
                int OriginalHeight = int.Parse(txtHeight.Text);
                int ContrastDegree = int.Parse(contrastTextBox.Text);

            ZGraphForm ZGF = new ZGraphForm("Contrast Time Execution Graph", "Window Size", "Time (ms)");

                if (textBox_MaxWindowSize.Text != "")
                {
                    int maxWindowSize = int.Parse(textBox_MaxWindowSize.Text);

                    // Make up some data points from contrast image
                    double[] x_values = new double[maxWindowSize+1];
                    double[] y_values_Normal = new double[maxWindowSize+1];
                    double[] y_values_Efficient = new double[maxWindowSize+1];

                    for (int i = 1; i <= maxWindowSize; i++)
                    {
                        x_values[i] = i;

                        MyColor[,] ResizedImage = ImageOperations.NormalResize(OriginalImageMatrix, OriginalWidth*i, OriginalHeight*i);

                        ImageOperations.ContrastImage_Normal(ResizedImage, ContrastDegree);
                        double NormalTime = ImageOperations.elapsedMs;
                        y_values_Normal[i] = NormalTime;

                        ImageOperations.ContrastImage_Efficient(ResizedImage, ContrastDegree);
                        double EfficientTime = ImageOperations.elapsedMs;
                        y_values_Efficient[i] = EfficientTime;
                    }

                    //Create a graph and add two curves to it
                    ZGF.add_curve("MinMax Normal Algorithm", x_values, y_values_Normal, Color.Red);
                    ZGF.add_curve("MinMax Efficient Algorithm", x_values, y_values_Efficient, Color.Blue);
                    ZGF.Show();
                }
            }
        }
        private void btnBlurGraph_Click(object sender, EventArgs e)
        {
            double[] xAxis = { 3, 5, 7, 9, 11, 13, 15, 17 };
            double[] yAxisBlurEfficient = new double[8];
            double[] yAxisBlurNotEfficient = new double[8];

            ZGraphForm graph = new ZGraphForm("Efficient and Non-Efficient Blur Algorithms", "Blur Mask Size", "Execution Time");

            for (int i = 0; i < xAxis.Length; i++)
            {
                MyColor[,] blurredImage = ImageOperations.BlurImage_Efficient(OriginalImageMatrix, (int)xAxis[i]);
                yAxisBlurEfficient[i] = ImageOperations.elapsedMs;
            }
            for (int i = 0; i < xAxis.Length; i++)
            {
                MyColor[,] blurredImage = ImageOperations.BlurImage_Normal(OriginalImageMatrix, (int)xAxis[i]);
                yAxisBlurNotEfficient[i] = ImageOperations.elapsedMs;
            }
            graph.add_curve("Non-Efficient Blur Algorithm", xAxis, yAxisBlurNotEfficient, Color.Red);
            graph.add_curve("Efficient Blur Algorithm", xAxis, yAxisBlurEfficient, Color.Green);
            graph.Show();
        }
Beispiel #3
0
        public static void draw(int wMax, GraphType g)
        {
            byte[,] dummyImage = ImageOperations.OpenImage("..\\..\\..\\..\\Images\\Uniform_and_Salt_Pepper.bmp");   //Using the "tiger" image as a dummy image to use in filtering.
            //Call: "(int)numMaxWindow_Graph.Value" as wMax value when you call this method (draw).

            ZGraphForm z;
            int        windowSize = 3;

            double[] x;
            double[] y;
            double[] y2;
            int      index = 0;
            int      before;
            int      after;
            int      size = ((wMax - 3) / 2) + 1;

            if (g == GraphType.ADAPTIVE_MEDIAN)
            {
                z = new ZGraphForm("Adaptive Median", "Window Size", "Time");
            }
            else
            {
                z = new ZGraphForm("Alpha Trim", "Window Size", "Time");
            }

            x  = new double[size];
            y  = new double[size];
            y2 = new double[size];

            while (windowSize <= wMax)
            {
                if (g == GraphType.ADAPTIVE_MEDIAN)
                {
                    AdaptiveMedianFilter adptvMdin;
                    //using Quick sort
                    before    = System.Environment.TickCount;
                    adptvMdin = new AdaptiveMedianFilter(dummyImage, windowSize);
                    adptvMdin.Filter(SortingType.QUICK_SORT);
                    after    = System.Environment.TickCount;
                    y[index] = after - before;

                    //using Counting Sort sort
                    int before2 = System.Environment.TickCount;
                    adptvMdin = new AdaptiveMedianFilter(dummyImage, windowSize);
                    adptvMdin.Filter(SortingType.COUNTING_SORT);
                    int after2 = System.Environment.TickCount;
                    y2[index] = after2 - before2;
                }

                else
                {
                    /*OPERATION*/
                    AlphaTrimFilter alphaTrim = new AlphaTrimFilter(dummyImage);    //Using a dummy/empty image here instead of 'ImageMatrix' (the real image object).

                    //Using KTH ELEMENT:
                    before = System.Environment.TickCount;
                    alphaTrim.removeNoise(windowSize, 4, SortingType.KTH_ELEMENT);  /*The 0 here is the trim value, constant.*/
                    after    = System.Environment.TickCount;
                    y[index] = after - before;

                    //Using COUNTING SORT:
                    before = System.Environment.TickCount;
                    alphaTrim.removeNoise(windowSize, 4, SortingType.COUNTING_SORT);
                    after     = System.Environment.TickCount;
                    y2[index] = after - before;
                }
                x[index]    = windowSize;
                windowSize += 2;
                index++;
            }
            if (g == GraphType.ADAPTIVE_MEDIAN)
            {
                z.add_curve("Quick Sort", x, y, System.Drawing.Color.Black);
                z.add_curve("Counting Sort", x, y2, System.Drawing.Color.Crimson);
            }
            else
            {
                z.add_curve("Kth Element", x, y, System.Drawing.Color.Black);
                z.add_curve("Counting Sort", x, y2, System.Drawing.Color.Crimson);
            }
            z.Show();
        }