Ejemplo n.º 1
0
        //从mat中得到矩阵值
        public void getData_Mat(myMat mat)
        {
            init_bytes(mat.height, mat.width);

            for (int i = 0; i < mat.height; i++)
            {
                for (int j = 0; j < mat.width; j++)
                {
                    img_data[i, j, 0] = mat.img_data[i, j, 0];
                    img_data[i, j, 1] = mat.img_data[i, j, 1];
                    img_data[i, j, 2] = mat.img_data[i, j, 2];
                }
            }
        }
Ejemplo n.º 2
0
        public void bend_distort(double a_max, double radius, string interp_method = "最近邻")
        {
            /*
             * 弯曲变换,将结果赋予resultImg
             * a_max: 最大旋转角度,角度制
             * radius: 旋转半径
             */
            resultImg = new myMat();
            double a_max_arc = a_max * System.Math.PI / 180;

            myMat.myCoor mid_p = new myMat.myCoor(inputImg.height / 2, inputImg.width / 2);
            resultImg.init_bytes(inputImg.height, inputImg.width);
            for (int i = 0; i < inputImg.height; i++)
            {
                for (int j = 0; j < inputImg.width; j++)
                {
                    myMat.myCoor sourceCoor = bend_source_coor(new myMat.myCoor(i, j), mid_p, a_max_arc, radius);
                    Color        c          = interp(sourceCoor, interp_method);
                    resultImg.set_rgb(c, new myMat.myCoor(i, j));
                }
            }
        }
Ejemplo n.º 3
0
        public void ball_distort(double height, string interp_method = "最近邻")
        {
            /*
             * 球形变换,将结果赋予resultImg
             * height: 球形变换的高度参数
             */
            resultImg = new myMat();
            double height_abs = System.Math.Abs(height);
            double m          = System.Math.Sqrt(inputImg.height * inputImg.height + inputImg.width * inputImg.width) / 2;
            double radius     = (height * height + m * m) / 2 / height_abs;

            myMat.myCoor mid_p = new myMat.myCoor(inputImg.height / 2, inputImg.width / 2);
            resultImg.init_bytes(inputImg.height, inputImg.width);
            for (int i = 0; i < inputImg.height; i++)
            {
                for (int j = 0; j < inputImg.width; j++)
                {
                    myMat.myCoor sourceCoor = ball_source_coor(new myMat.myCoor(i, j), mid_p, radius, direction: (int)(height / height_abs));
                    Color        c          = interp(sourceCoor, interp_method);
                    resultImg.set_rgb(c, new myMat.myCoor(i, j));
                }
            }
        }
Ejemplo n.º 4
0
 public void setInputImg(Bitmap bm)
 {
     inputImg = new myMat();
     inputImg.getData_bitmap(bm);
 }