Ejemplo n.º 1
0
        /// <summary>
        /// 归一化方法 两个矩阵对比得值
        /// </summary>
        /// <param name="tempM">S</param>
        /// <param name="PicMatch">r</param>
        /// <returns></returns>
        private double MatchGuiYiHuaCompare(double[,] matrixS, double[,] matrixR)
        {
            //
            double dRtn = 0.0;

            // 矩阵求平均值.
            double dMeanS = BasePicHandle.MatrixMean(matrixS);
            double dMeanR = BasePicHandle.MatrixMean(matrixR);

            int nRow = BasePicHandle.GetROW(matrixR);
            int nCol = BasePicHandle.GetCOL(matrixR);


            //

            double dsOff      = 0.0;
            double drOff      = 0.0;
            double dFenzi     = 0.0;
            double dFenziTemp = 0.0;

            double dsPingFang = 0.0;
            double drPingFang = 0.0;
            double dFront     = 0.0;
            double dBack      = 0.0;

            for (int i = 0; i < nRow; i++)
            {
                for (int j = 0; j < nCol; j++)
                {
                    dsOff      = matrixS[i, j] - dMeanS;
                    drOff      = matrixR[i, j] - dMeanR;
                    dFenziTemp = dsOff * drOff;
                    dFenzi     = dFenzi + dFenziTemp;


                    dsPingFang = dsOff * dsOff;
                    dFront     = dFront + dsPingFang;

                    drPingFang = drOff * drOff;
                    dBack      = dBack + drPingFang;
                }
            }



            // 分母
            double dFenmu = Math.Sqrt(dFront * dBack);


            dRtn = dFenzi / dFenmu;


            return(dRtn);
        }
Ejemplo n.º 2
0
        // 为矩阵赋值一个值
        public static void SetMatrixValue(byte[,] whitePic, byte nColor)
        {
            int nRow = BasePicHandle.GetROW(whitePic);
            int nCol = BasePicHandle.GetCOL(whitePic);

            for (int i = 0; i < nRow; i++)
            {
                for (int j = 0; j < nCol; j++)
                {
                    whitePic[i, j] = nColor;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 求矩阵平均值.
        /// </summary>
        /// <param name="tempM"></param>
        public static double MatrixMean(double[,] tempM)
        {
            double dRtn = 0.0;

            int nRow = BasePicHandle.GetROW(tempM);
            int nCol = BasePicHandle.GetCOL(tempM);

            for (int i = 0; i < nRow; i++)
            {
                for (int j = 0; j < nCol; j++)
                {
                    dRtn = dRtn + tempM[i, j];
                }
            }

            dRtn = dRtn / (nRow * nCol);

            return(dRtn);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 对JPG图片改变像素来达到画线条的目的
        /// </summary>
        /// <param name="tempImage"></param>
        /// <param name="MatchPic"></param>
        /// <param name="getLocation"></param>
        public static void DrawRetangle(Image tempImage, double[,] MatchPic, Location getLocation)
        {
            // 从这个点画一个小图大小的白框(灰度时 值为255) 在大图Basepic上面画小图
            int nSizeDrawRow = BasePicHandle.GetROW(MatchPic);
            int nSizeDrawCol = BasePicHandle.GetCOL(MatchPic);


            // 偏移指针 基准点的值
            int OFFRow = getLocation.row;
            int OFFCol = getLocation.column;

            // Bitmap bmp = new Bitmap("ir.tif");
            Graphics g = Graphics.FromImage(tempImage);

            int matchRow = BasePicHandle.GetROW(MatchPic);
            int matchCol = BasePicHandle.GetCOL(MatchPic);

            g.DrawRectangle(new Pen(Color.White), OFFCol, OFFRow, matchRow, matchCol);
        }