Beispiel #1
0
        public static ImageWave WaweinPicture(int width, int height)
        {
            //Создаем матрицу значений
            WaveletMatrix matrix   = new WaveletMatrix();
            List <Node>   nodeList = new List <Node>();

            double chastot = Const.Chastota / width;
            double step = Const.step / height;
            double move, scale;

            //Вычисление матрицы значений
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    move  = x * chastot;
                    scale = y * step + 0.1;
                    Coordinate coordinate = new Coordinate(x, y);
                    double     value      = 1.0 / Math.Sqrt(Math.Abs(scale)) * getIntegral(move, scale);
                    nodeList.Add(new Node(coordinate, value));
                }
            }

            //Задаем список элементов значений матрицs посчитаных
            matrix.setNodeList(nodeList);

            //Приводим матрицу вычисленных значений к пиксельной матрице
            //** в пиксельной max = 255(белый цвет), min = 0(черный)
            double min = matrix.getMinNode(nodeList);
            double max = matrix.getMaxNode(nodeList);


            //Создаем изображение
            ImageWave     image      = new ImageWave(width, height);
            List <Pixels> pixelsList = new List <Pixels>();

            foreach (Node node in matrix.getNodeList())
            {
                Coordinate coordinate = node.getCoordinate();
                int        color      = (int)((node.getValue() - min) * (255 / (max - min)));
                pixelsList.Add(new Pixels(coordinate, color));
            }
            image.setPixels(pixelsList);

            return(image);
        }
Beispiel #2
0
        private void button_Converting_Click(object sender, EventArgs e)
        {
            width  = pictureBox_Wavelet.Width;
            height = pictureBox_Wavelet.Height;
            ImageWave image = CalcCustom.WaweinPicture(width, height);


            Bitmap bmp = new Bitmap(width, height);
            int    r, g, b;

            foreach (Pixels pixel in image.getPixels())
            {
                r = g = b = pixel.getColor();
                bmp.SetPixel((int)pixel.getCoordinate().getX(), (int)pixel.getCoordinate().getY(), Color.FromArgb(r, g, b));
                pictureBox_Wavelet.Image = bmp;
            }
        }