Example #1
0
        public static Recatangle Image2UserCoordinateSystem(Recatangle target)
        {
            List <Matrix> ctms = new List <Matrix>();

            Recatangle rect_10 = new Recatangle(new Point(0, 1), 1, 1);

            double[][] p1 = new double[][] {
                new double[] { 404.5714, 0, 0 },
                new double[] { 0, 213.4286, 0 },
                new double[] { 0, -213.4286, 1 }
            };
            double[][] p2 = new double[][] {
                /**
                 * new double[]{ 0.00185381, 0,0 },
                 * new double[]{ 0, 0.00351407,0 },
                 * **/

                new double[] { 0.00185381, 0, 0 },
                new double[] { 0, 0.00351407, 0 },
                new double[] { 0, 0, 1 }

                /**
                 * new double[]{ 1, 0,0 },
                 * new double[]{ 0,1,0 },
                 * new double[]{ 0, 0,1 }
                 * **/
            };

            double[][] p21 = new double[][] {
                new double[] { 1, 0, 0 },
                new double[] { 0, 1, 0 },
                new double[] { 0, 0, 1 }
            };

            double[][] p3 = new double[][] {
                new double[] { 1, 0, 0 },
                new double[] { 0, 1, 0 },
                new double[] { 0, -257.785, 1 }
            };

            double[][] p4 = new double[][] {
                new double[] { 1, 0, 0 },
                new double[] { 0, 1, 0 },
                new double[] { 0, 257.785, 1 }
            };

            Matrix m1  = new Matrix(p1);
            Matrix m2  = new Matrix(p2);
            Matrix m21 = new Matrix(p21);
            Matrix m3  = new Matrix(p3);
            Matrix m4  = new Matrix(p4);

            ctms.Add(m1);
            ctms.Add(m2);
            ctms.Add(m21);
            ctms.Add(m3);
            ctms.Add(m4);



            Console.WriteLine("###########Image2PatternCoordinateSystem##############");
            //本类中调用,得到的ImageRect结果是没有映射到用户坐标空间中,只是映射到了Pattern坐标空间中

            Recatangle imageRect = Image2pattern.Image2patternSystem(rect_10, ctms, target);



            Console.WriteLine("###########ImageRect finished!!!##############");
            Recatangle    BBOX  = new Recatangle(new Point(-5, 5), 387.19, 257.785);
            List <Matrix> ctms1 = new List <Matrix>();

            ctms1.Add(new Matrix(new double[][] {
                new double[] { 4 / 3.0000, 0, 0 },
                new double[] { 0, 4 / 3.0000, 0 },
                new double[] { 0, 792, 1 }
            }));
            Recatangle imageRect1 = null;

            //在本类中调用
            imageRect1 = Image2pattern.BBOX2CoordinateSystem(imageRect, ctms1, target);
            Console.WriteLine("================" + imageRect1);
            Console.WriteLine("imageRect");
            Matrix.PrintMatrix(Matrix.ConvertRect2Arr(imageRect1));
            BBOX = Image2pattern.BBOX2CoordinateSystem(BBOX, ctms1, target);
            Console.WriteLine(BBOX);

            Console.WriteLine("###########BBOX finished!!!##############");


            Console.WriteLine("imageRect");
            Console.WriteLine("<<<<<<<<<<<<<<<<" + imageRect1);
            Matrix.PrintMatrix(Matrix.ConvertRect2Arr(imageRect1));


            Console.WriteLine("BBOX");
            Matrix.PrintMatrix(Matrix.ConvertRect2Arr(BBOX));


            Console.WriteLine("相交面积");
            Console.WriteLine(Rectangles.getSequare(BBOX, imageRect1));
            Console.WriteLine();


            return(imageRect);
        }
Example #2
0
        private static void Image2PatternCoordinateSystem()
        {
            Console.WriteLine("==========================");
            Recatangle    rect_10 = new Recatangle(new Point(0, 1), 1, 1);
            List <Matrix> ctms    = new List <Matrix>();

            double[][] p1 = new double[][] {
                new double[] { 404.5714, 0, 0 },
                new double[] { 0, 213.4286, 0 },
                new double[] { 0, -213.4286, 1 }
            };
            double[][] p2 = new double[][] {
                new double[] { 0.00185381, 0, 0 },
                new double[] { 0, 0.00351407, 0 },
                new double[] { 0, 0, 1 }
            };
            double[][] p3 = new double[][] {
                new double[] { 1, 0, 0 },
                new double[] { 0, 1, 0 },
                new double[] { 0, -257.785, 1 }
            };

            double[][] p4 = new double[][] {
                new double[] { 1, 0, 0 },
                new double[] { 0, 1, 0 },
                new double[] { 0, 257.785, 1 }
            };

            Matrix m1 = new Matrix(p1);
            Matrix m2 = new Matrix(p2);
            Matrix m3 = new Matrix(p3);
            Matrix m4 = new Matrix(p4);

            ctms.Add(m1);
            ctms.Add(m2);
            ctms.Add(m3);
            ctms.Add(m4);
            //Console.WriteLine(PDF2User.setCTMTransform(rect_10, ctms));


            Console.WriteLine("###########Image2PatternCoordinateSystem##############");
            Recatangle imageRect = PDF2User.setCTMTransform(rect_10, ctms);

            Console.WriteLine("###########ImageRect finished!!!##############");
            Recatangle    BBOX  = new Recatangle(new Point(-5, 5), 387.19, 257.785);
            List <Matrix> ctms1 = new List <Matrix>();

            ctms1.Add(new Matrix(new double[][] {
                new double[] { 4 / 3.0000, 0, 0 },
                new double[] { 0, 4 / 3.0000, 0 },
                new double[] { 0, 792, 1 }
            }));
            BBOX = PDF2User.setCTMTransform(BBOX, ctms);
            Console.WriteLine("###########BBOX finished!!!##############");


            Console.WriteLine("imageRect");
            Matrix.PrintMatrix(Matrix.ConvertRect2Arr(imageRect));


            Console.WriteLine("BBOX");
            Matrix.PrintMatrix(Matrix.ConvertRect2Arr(BBOX));



            Console.WriteLine("相交面积");
            Console.WriteLine(Rectangles.getSequare(imageRect, BBOX));
            Console.WriteLine();
            //Console.ReadKey();
        }