public void RasterBandPickValueTool()
        {
            GRasterLayer          rasterLayer           = new GRasterLayer(fullFilename);
            IRasterBandCursorTool pRasterBandCursorTool = new GRasterBandCursorTool();

            pRasterBandCursorTool.Visit(rasterLayer.BandCollection[0]);
            double normalValue = pRasterBandCursorTool.PickNormalValue(100, 100);

            //the col and row should be odd number
            double[] rangeNormalValue = pRasterBandCursorTool.PickRangeNormalValue(100, 100, 3, 3);
            double   rawValue         = pRasterBandCursorTool.PickRawValue(100, 100);

            //the col and row should be odd number
            double[] rangeRawValue = pRasterBandCursorTool.PickRangeRawValue(100, 100, 3, 3);
            //
            Assert.AreEqual(normalValue, 0.62204724409448819);
            Assert.AreEqual(string.Join(",", rangeNormalValue), "0.645669291338583,0.637795275590551,0.661417322834646,0.614173228346457,0.622047244094488,0.645669291338583,0.614173228346457,0.618110236220472,0.622047244094488");
            Assert.AreEqual(rawValue, 159);
            Assert.AreEqual(string.Join(",", rangeRawValue), "165,163,169,157,159,165,157,158,159");
        }
 public JobCOVRaster(GRasterBand target1band, GRasterBand target2band)
 {
     _t = new Thread(() => {
         IRasterBandCursorTool pRasterBandCursorTool1 = new GRasterBandCursorTool();
         IRasterBandCursorTool pRasterBandCursorTool2 = new GRasterBandCursorTool();
         pRasterBandCursorTool1.Visit(target1band);
         pRasterBandCursorTool2.Visit(target2band);
         //
         int seed        = 0;
         int totalPixels = target1band.Width * target1band.Height;
         Bitmap bitmap   = new Bitmap(target1band.Width, target1band.Height);
         Graphics g      = Graphics.FromImage(bitmap);
         //
         for (int i = 0; i < target1band.Width; i++)
         {
             for (int j = 0; j < target1band.Height; j++)
             {
                 double[] raw1 = pRasterBandCursorTool1.PickRangeRawValue(i, j, 3, 3);
                 double[] raw2 = pRasterBandCursorTool2.PickRangeRawValue(i, j, 3, 3);
                 double cov    = ConvarianceIndex.CalcuteConvarianceIndex(raw1, raw2);
                 //拉伸-1 - 1
                 int gray         = Convert.ToInt32((cov + 1.0) * 20);
                 Color c          = Color.FromArgb(gray, gray, gray);
                 Pen p            = new Pen(c);
                 SolidBrush brush = new SolidBrush(c);
                 g.FillRectangle(brush, new Rectangle(i, j, 1, 1));
                 Process = (double)(seed++) / totalPixels;
             }
         }
         //save result
         string fullFileName = Directory.GetCurrentDirectory() + @"\tmp\" + DateTime.Now.ToFileTimeUtc() + ".png";
         bitmap.Save(fullFileName);
         //
         Summary  = "计算完成";
         Complete = true;
         OnTaskComplete?.Invoke(Name, fullFileName);
     });
 }