示例#1
0
        private void button14_Click(object sender, EventArgs e)
        {
            //构造参数提供者
            string fname               = @"f:\\FY3A_Mersi_2010_06_24_10_00_1000M_L1B_PRJ_Whole.LDF";
            IRasterDataProvider prd    = GeoDataDriver.Open(fname) as IRasterDataProvider;
            ArgumentProvider    argprd = new ArgumentProvider(prd, null);
            //构造判识表达式
            //string express = "(band4 + band3) == 0? 0f : (band4 - band3) / (float)(band4 + band3)";
            string express = "NDVI(band4,band3)";

            int[] bandNos = new int[] { 4, 3 };
            //构造栅格计算判识器
            IRasterExtracter <UInt16, float> extracter = new SimpleRasterExtracter <UInt16, float>();

            extracter.Reset(argprd, bandNos, express);
            //判识
            resultNDVI = new MemPixelFeatureMapper <float>("NDVI", 1000, new Size(prd.Width, prd.Height), prd.CoordEnvelope, prd.SpatialRef);
            Stopwatch sw = new Stopwatch();

            sw.Start();
            extracter.Extract(resultNDVI);
            //sw.Stop();
            //Text = sw.ElapsedMilliseconds.ToString();
            //判识结果生成二值位图
            //IBinaryBitmapBuilder builder = new BinaryBitmapBuilder();
            //Size bmSize = new Size(prd.Width / 2, prd.Height / 2);
            //Bitmap bitmap = builder.CreateBinaryBitmap(bmSize, Color.Red, Color.Transparent);
            //builder.Fill(idxs, new Size(prd.Width, prd.Height), ref bitmap);
            //bitmap.Save("f:\\1.png", ImageFormat.Png);
            //判识结果永久保存
            RasterIdentify id = new RasterIdentify();

            id.ThemeIdentify      = "CMA";
            id.ProductIdentify    = "FIR";
            id.SubProductIdentify = "NDVI";
            id.Satellite          = "FY3A";
            id.Sensor             = "MERSI";
            id.Resolution         = "250M";
            id.OrbitDateTime      = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0));
            id.GenerateDateTime   = DateTime.Now;
            IInterestedRaster <float> iir = new InterestedRaster <float>(id, new Size(prd.Width, prd.Height), prd.CoordEnvelope.Clone());

            iir.Put(resultNDVI);
            iir.Dispose();
            sw.Stop();
            Text = sw.ElapsedMilliseconds.ToString();

            int count = iir.Count(aoi, (v) => { return(v == 1); });

            iir.Count(aoi, (v) => { return((int)v); });
        }