Exemple #1
0
        private void renderDisplayImageBoundaryFinderV1()
        {
            int imgWidth = pctBx_Display.Width, imgHeight = pctBx_Display.Height;


            double adjPlotScale = PlotScale * MaxPlotScale;

            PointD firstPixelGCoord = new PointD(
                Plot_CenterCoord.X - 0.5d * adjPlotScale * imgWidth,
                Plot_CenterCoord.Y - 0.5d * adjPlotScale * imgHeight
                );

            Complex[,] lattice = new Complex[imgWidth, imgHeight];
            for (int i = 0; i < imgWidth; i++)
            {
                for (int j = 0; j < imgHeight; j++)
                {
                    lattice[i, j] = new Complex(i * adjPlotScale + firstPixelGCoord.X, j * adjPlotScale + firstPixelGCoord.Y);
                }
            }

            int     workers                     = 32;
            int     maxIterations               = 100;
            int     numPasses                   = 3;
            int     numPoints                   = 10;
            double  etaDecreaseFactor           = 10;
            double  maxIterationsIncreaseFactor = 1.5;
            double  numPointsIncreaseFactor     = 1.5;
            double  additionalPassThreshold     = 0.8;
            Complex eta = new Complex(1, 1);

            double[,] sumLattice        = new double[imgWidth, imgHeight];
            bool[,] needsAdditionalPass = new bool[imgWidth, imgHeight];
            for (int p = 0; p < numPasses; p++)
            {
                eta           = new Complex(eta.Real / etaDecreaseFactor, eta.Imaginary / etaDecreaseFactor);
                maxIterations = (int)((double)maxIterations * maxIterationsIncreaseFactor);
                numPoints     = (int)((double)numPoints * numPointsIncreaseFactor);

                Parallel.For(0, workers, index =>
                {
                    for (int i = (int)(((double)index / workers) * imgWidth); i < (int)(((double)(index + 1) / workers) * imgWidth); i++)
                    {
                        for (int j = 0; j < imgHeight; j++)
                        {
                            if (p == 0 || needsAdditionalPass[i, j])
                            {
                                sumLattice[i, j]          = computeSumBoundaryFinderV1(lattice[i, j], eta, maxIterations, adjPlotScale, numPoints);
                                needsAdditionalPass[i, j] = (sumLattice[i, j] >= additionalPassThreshold);
                                if (!needsAdditionalPass[i, j])
                                {
                                    sumLattice[i, j] = 0;
                                }
                            }
                        }
                    }
                }
                             );
            }

            pctBx_Display.Image = new Bitmap(imgWidth, imgHeight);
            int juliaColor;

            for (int i = 0; i < imgWidth; i++)
            {
                for (int j = 0; j < imgHeight; j++)
                {
                    juliaColor = (int)(sumLattice[i, j] * 255) % 255;
                    ((Bitmap)pctBx_Display.Image).SetPixel(i, j, Color.FromArgb(juliaColor, juliaColor, juliaColor));
                }
            }

            pctBx_Display.Refresh();
            System.Media.SystemSounds.Beep.Play();
        }
Exemple #2
0
        private void renderDisplayImageCAUCHYV1()
        {
            int imgWidth = pctBx_Display.Width, imgHeight = pctBx_Display.Height;


            double adjPlotScale = PlotScale * MaxPlotScale;

            PointD firstPixelGCoord = new PointD(
                Plot_CenterCoord.X - 0.5d * adjPlotScale * imgWidth,
                Plot_CenterCoord.Y - 0.5d * adjPlotScale * imgHeight
                );

            Complex[,] lattice = new Complex[imgWidth, imgHeight];
            for (int i = 0; i < imgWidth; i++)
            {
                for (int j = 0; j < imgHeight; j++)
                {
                    lattice[i, j] = new Complex(i * adjPlotScale + firstPixelGCoord.X, j * adjPlotScale + firstPixelGCoord.Y);
                }
            }

            int     maxIterations = 100;
            Complex eta           = new Complex(1e-300, 1e-300);

            double[,] sumLattice = new double[imgWidth, imgHeight];
            int workers = 32;

            Parallel.For(0, workers, index =>
            {
                for (int i = (int)(((double)index / workers) * imgWidth); i < (int)(((double)(index + 1) / workers) * imgWidth); i++)
                {
                    for (int j = 0; j < imgHeight; j++)
                    {
                        sumLattice[i, j] = computeSum(lattice[i, j], eta, maxIterations);
                    }
                }
            }
                         );

            double delta = 1e-20, expv, stdev;

            computeStats(sumLattice, delta, out expv, out stdev);

            double K = expv + 0.5 * stdev;

            double[,] juliaLattice = new double[imgWidth, imgHeight];
            for (int i = 0; i < imgWidth; i++)
            {
                for (int j = 0; j < imgHeight; j++)
                {
                    juliaLattice[i, j] = Math.Log(delta + sumLattice[i, j]) - K;
                }
            }

            pctBx_Display.Image = new Bitmap(imgWidth, imgHeight);
            decimal juliaColor;

            for (int i = 0; i < imgWidth; i++)
            {
                for (int j = 0; j < imgHeight; j++)
                {
                    //juliaColor = (int)((juliaLattice[i, j] / (4 * stdev))*255) % 255;
                    juliaColor = (decimal)(0.5 + (1 / Math.PI * Math.Atan(Math.PI * 1 * juliaLattice[i, j])));

                    if (juliaLattice[i, j] > 0)
                    {
                        ((Bitmap)pctBx_Display.Image).SetPixel(i, j, Color.White);
                    }
                    //((Bitmap)pctBx_Display.Image).SetPixel(i, j, PaletteManager.CurrentPalette.getColor(juliaColor));
                    else
                    {
                        ((Bitmap)pctBx_Display.Image).SetPixel(i, j, Color.Black);
                    }
                }
            }

            pctBx_Display.Refresh();
            System.Media.SystemSounds.Beep.Play();
        }