Пример #1
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            if (textBand1.Text == "" || textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" ||
                textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || textBox7.Text == "" ||
                textBox8.Text == "" || textBox9.Text == "" || textBox10.Text == "" ||
                txtHeight.Text == "" || txtSaveFile.Text == "")
            {
                MessageBox.Show("请检查输入、输出以及参数设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                //开始水汽计算程序
                try
                {
                    COM_IDL_connectLib.COM_IDL_connect oCom = new COM_IDL_connectLib.COM_IDL_connect();
                    oCom.CreateObject(0, 0, 0);

                    //oCom.ExecuteString("window,1,title='C#call IDL'");
                    //oCom.ExecuteString("plot,sin(findgen(200)/20)");
                    //oCom.DestroyObject();

                    oCom.SetIDLVariable("imagePath1", textBand1.Text);                                    //热红外劈窗通道图像1
                    oCom.SetIDLVariable("imagePath2", textBox1.Text);                                     //热红外劈窗通道图像2
                    oCom.SetIDLVariable("imagePath3", textBox2.Text);                                     //红外波段图像
                    oCom.SetIDLVariable("imagePath4", textBox3.Text);                                     //近红外通道图像

                    oCom.SetIDLVariable("band1", Convert.ToDouble(txtHeight.Text));                       //劈窗通道波长1
                    oCom.SetIDLVariable("band2", Convert.ToDouble(textBox4.Text));                        //劈窗通道波长2
                    oCom.SetIDLVariable("BareSoilNDVIThresholdValue", Convert.ToDouble(textBox6.Text));   //裸土NDVI阈值
                    oCom.SetIDLVariable("vegetationNDVIThresholdValue", Convert.ToDouble(textBox5.Text)); //植被NDVI阈值
                    oCom.SetIDLVariable("BareSoilEmissivity1", Convert.ToDouble(textBox8.Text));          //裸土发射率1
                    oCom.SetIDLVariable("BareSoilEmissivity2", Convert.ToDouble(textBox7.Text));          //裸土发射率2
                    oCom.SetIDLVariable("vegetationEmissivity1", Convert.ToDouble(textBox10.Text));       //植被发射率1
                    oCom.SetIDLVariable("vegetationEmissivity2", Convert.ToDouble(textBox9.Text));        //植被发射率2
                    oCom.SetIDLVariable("windowSize1", Convert.ToDouble(textBox12.Text));                 //窗口设置1
                    oCom.SetIDLVariable("windowSize2", Convert.ToDouble(textBox13.Text));                 //窗口设置2

                    //oCom.SetIDLVariable("outputdir", txtSaveFile.Text);

                    string tmp = "splitpwv_jicheng,'" + textBand1.Text + "','" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + txtSaveFile.Text.ToString()
                                 + "'," + Convert.ToDouble(txtHeight.Text) + "," + Convert.ToDouble(textBox4.Text) + "," + Convert.ToDouble(textBox12.Text) + "," + Convert.ToDouble(textBox13.Text)
                                 + "," + Convert.ToDouble(textBox6.Text) + "," + Convert.ToDouble(textBox5.Text) + "," + Convert.ToDouble(textBox8.Text) + "," + Convert.ToDouble(textBox7.Text)
                                 + "," + Convert.ToDouble(textBox10.Text) + "," + Convert.ToDouble(textBox9.Text) + "";
                    Console.WriteLine(tmp);
                    string tmp2 = ".compile '" + Application.StartupPath.ToString() + "\\splitpwv_jicheng.pro'";
                    oCom.ExecuteString(tmp2);
                    oCom.ExecuteString(tmp);
                    //oCom.ExecuteString("splitpwv_jicheng,imagePath1,imagePath2,imagePath3,imagePath4,outputdir,band1,band2,windowSize1,windowSize2,BareSoilNDVIThresholdValue,vegetationNDVIThresholdValue,BareSoilEmissivity1,BareSoilEmissivity2,vegetationEmissivity1,vegetationEmissivity2");
                    oCom.DestroyObject();


                    //oCom.ExecuteString("Restore,'splitpww.sav'");//编译程序
                    //oCom.ExecuteString("splitpww");
                    //oCom.ExecuteString(tmp);

                    MessageBox.Show("运行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #2
0
        public void run_histogram(int bandIndex)
        {
            filepath = raster_layer.FilePath;
            oCom.CreateObject(0, 0, 0);
            //oCom.ExecuteString(".RESET_SESSION");
            //图像熵测试
            string input = filepath;  //输入影像
            int    pos   = bandIndex; //波段,0为第一波段,1为第二波段······

            //string tmp1 = "image_entropy20140607,'" + input + "'," + pos + ",imageentropy=imageentropy";
            //oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\image_entropy20140607.pro'");
            //try
            //{
            //    oCom.ExecuteString(tmp1);
            //    StatusImageShang_Value.Text = oCom.GetIDLVariable("imageentropy").ToString();//输出图像熵
            //}
            //catch
            //{
            //    StatusImageShang_Value.Text = "NaN";
            //}
            //最大,最小,平均值,标准差,直方图(纵坐标和横坐标),信息熵,平均梯度、清晰度
            try
            {
                string tmp2 = "IMAGE_STATISTICS20150306," + "\"" + input + "\"," + pos + "," + "image_dmax=image_dmax,image_dmin=image_dmin,image_dmean=image_dmean,image_stdv=image_stdv,image_hist=image_hist,binb=binb,p1=p1,g1=g1,outdata2=outdata2";
                oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\IMAGE_STATISTICS20150306.pro'");
                oCom.ExecuteString(tmp2);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Array image_max = (Array)oCom.GetIDLVariable("image_dmax");//输出像元最大值

            labelMax.Text = Math.Round(Convert.ToDecimal(image_max.GetValue(0)), 6).ToString();
            x_max         = Convert.ToDouble(image_max.GetValue(0).ToString());

            Array image_min = (Array)oCom.GetIDLVariable("image_dmin");//输出像元最小值

            labelMin.Text = Math.Round(Convert.ToDecimal(image_min.GetValue(0)), 6).ToString();
            x_min         = Convert.ToDouble(image_min.GetValue(0).ToString());

            Array image_mean = (Array)oCom.GetIDLVariable("image_dmean");//输出像元均值

            labelMean.Text = Math.Round(Convert.ToDecimal(image_mean.GetValue(0)), 6).ToString();

            Array image_stdv = (Array)oCom.GetIDLVariable("image_stdv");//输出像元方差

            labelStd.Text = Math.Round(Convert.ToDecimal(image_stdv.GetValue(0)), 6).ToString();

            y_value = (Array)oCom.GetIDLVariable("image_hist"); //输出直方图值(纵坐标)
            x_value = (Array)oCom.GetIDLVariable("binb");       //输出直方图值(橫坐标)

            dataToDatagridview(x_value, y_value);

            object p1 = oCom.GetIDLVariable("p1");//输出信息熵

            labelEntropy.Text = Math.Round(Convert.ToDecimal(p1), 6).ToString();

            object g1 = oCom.GetIDLVariable("g1");//输出平均梯度

            labelMeanTiDu.Text = Math.Round(Convert.ToDecimal(g1), 6).ToString();

            object outdata2 = oCom.GetIDLVariable("outdata2");//输出清晰度

            labelArticulation.Text = Math.Round(Convert.ToDecimal(outdata2), 6).ToString();

            CreateGraph(zg1, x_value, y_value, x_min, x_max);
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //图像拉伸
            string input   = filepath;
            string in_min  = txt_in_min.Text;  // "12";//输入最小要拉伸的值
            string in_max  = txt_in_max.Text;  // "109";//输入最大要拉伸的值
            string out_min = txt_out_min.Text; // "0";//输出最小值
            string out_max = txt_out_max.Text; // "255";//输出最大值

            //判断是否输出影像文件
            if (fileoutpath != "")
            {
                out_name = fileoutpath;// "D:\\20090823_4_254_597_linear001.tif";//输出文件名
            }
            else
            {
                //首次运行,删除TempImage文件夹下所有文件
                if (!flag)
                {
                    try
                    {
                        Directory.Delete(Application.StartupPath + "\\TempImage", true);
                        Directory.CreateDirectory(Application.StartupPath + "\\TempImage");
                        flag = true;
                    }
                    catch { }
                }
                out_name = Application.StartupPath + "\\TempImage\\temp_stretch.tif";
                while (File.Exists(out_name))
                {
                    out_name = out_name.Replace(".tif", "_.tif");
                }
            }

            //判断选择波段
            if (cmbLayerBand.SelectedItem != null)
            {
                pos = Convert.ToString(cmbLayerBand.SelectedIndex);
            }
            string method         = (cmb_method.SelectedIndex + 1).ToString(); // "1";//选择拉伸方法,1 Linear ,2 Equalize,3 Gaussian ,4 Square root
            string ValueOrPercent = "1";                                       //输入值得类型,0为百分比,1为数值
            string tmp3           = "image_stretching20150306," + "\"" + input + "\"," + pos + "," + in_min + "," + in_max + "," + out_min + "," + out_max + ",\"" + out_name + "\"," + method + "," + ValueOrPercent;

            try
            {
                oCom.CreateObject(0, 0, 0);
                oCom.ExecuteString(".compile '" + Application.StartupPath.ToString() + "\\image_stretching20150306.pro'");
                oCom.ExecuteString(tmp3);
                axMapControl1.DeleteLayer(0);
                axMapControl1.Map.AddLayer(createLayer(out_name));
                axMapControl1.Refresh();
                if (fileoutpath != "")
                {
                    MessageBox.Show("拉伸成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }