private void selectRasterCmb_SelectedIndexChanged(object sender, EventArgs e) { if (selectDBCmb.Text == null || selectRasterCmb.Text == null) { return; } RBandCmb.Items.Clear(); GBandCmb.Items.Clear(); BBandCmb.Items.Clear(); rds = new RasterDataSet(GDB); rds.Open(selectRasterCmb.Text, 0); //将波段添加到各个comoBox中 for (int i = 0; i < rds.GetBandNum(); i++) { RasBand = rds.GetRasterBand(i + 1); RBandCmb.Items.Add("波段" + (i + 1)); GBandCmb.Items.Add("波段" + (i + 1)); BBandCmb.Items.Add("波段" + (i + 1)); } //在地图空间中显示该图层 Map map = new Map(); themeLayer = new RasterLayer(); if (rds != null) { themeLayer.AttachData(rds); } map.Append(themeLayer); this.mapControl.ActiveMap = map; this.mapControl.Restore(); RBandCmb.Text = ""; GBandCmb.Text = ""; BBandCmb.Text = ""; if (RBandCmb.Items.Count >= 3 && GBandCmb.Items.Count >= 3 && BBandCmb.Items.Count >= 3) { RBandCmb.Enabled = true; GBandCmb.Enabled = true; BBandCmb.Enabled = true; RBandCmb.SelectedIndex = 0; GBandCmb.SelectedIndex = 1; BBandCmb.SelectedIndex = 2; } else { RBandCmb.Enabled = false; GBandCmb.Enabled = false; BBandCmb.Enabled = false; } //显示图像信息 height = rds.GetPixelHeight(); width = rds.GetPixelWidth(); labelHeight.Text = height.ToString(); labelWidth.Text = Width.ToString(); labelHeight.Visible = true; labelWidth.Visible = true; //显示图像分辨率 resolutionX = rds.GetResolutionX(); resolutionY = rds.GetResolutionY(); labelResolutionX.Text = resolutionX.ToString(); labelResolutionY.Text = resolutionY.ToString(); labelResolutionX.Visible = true; labelResolutionY.Visible = true; //给分类器设置参数 /* * textBox2.Text = "4"; * textBox3.Text = "16"; * textBox4.Text = "20"; * textBox5.Text = "0.01"; * textBox9.Text = "0.005"; * textBox8.Text = "9.8"; * textBox7.Text = "5"; * textBox6.Text = "6.4"; */ }
private void button_Click(object sender, EventArgs e) { //获取参数 //原始图像路径 string OriRasURL = "GDBP://MapGisLocal/" + selectDBCmb1.Text + "/ras/" + selectRasterCmb1.Text; //分类图像路径 string ClsRasURL = "GDBP://MapGisLocal/" + selectDBCmb2.Text + "/ras/" + selectRasterCmb2.Text; //评价结果路径 string result = resultPath.Text; //统计参数 bool ErrMatrix = false; bool ClsAccu = false; bool TtlAccu = false; bool Kappa = false; if (this.ErrMatrix.Checked == true) { ErrMatrix = true; } if (this.ClsAccu.Checked == true) { ClsAccu = true; } if (this.TtlAccu.Checked == true) { TtlAccu = true; } if (this.Kappa.Checked == true) { Kappa = true; } RasterDataSet ori_rds = new RasterDataSet(); RasterDataSet cls_rds = new RasterDataSet(); ori_rds.OpenByURL(OriRasURL, RasAccessType.RasAccessType_Update); cls_rds.OpenByURL(ClsRasURL, RasAccessType.RasAccessType_Update); //显示图像信息 height = cls_rds.GetPixelHeight(); width = cls_rds.GetPixelWidth(); //生成评价器 RasClassificationAnalyse rca = new RasClassificationAnalyse(); //设置初始参数 rca.SetData(cls_rds, cls_rds.BandCount); //设置处理范围 rca.SetCommonParam(0, 0, height, width); //调用评价器 int i = rca.RsClassificationAccuracyAnalyse(ori_rds, ErrMatrix, ClsAccu, TtlAccu, Kappa, result); if (i > 0) { MessageBox.Show("精度评价完成!"); } else { MessageBox.Show("精度评价失败!"); } }