private void Close_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null || treeView1.SelectedNode.Parent != null)
            {
                MessageBox.Show("请选中父节点!");
                return;
            }
            if (treeView1.SelectedNode.Parent == null)
            {
                DialogResult ReturnDlg = MessageBox.Show(this, "Be sure to Close Selected File?", "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                switch (ReturnDlg)
                {
                case DialogResult.OK:
                    //GetDataByFilename gdbf =new GetDataByFilename();
                    int i = new GetDataByFilename().getnumber(Form1.boduan, treeView1.SelectedNode.Text);
                    Form1.boduan.RemoveAt(i);
                    this.readmore.RemoveAt(i);
                    this.treeView1.Nodes.Remove(treeView1.SelectedNode);
                    break;

                case DialogResult.Cancel:
                    break;
                }
            }
        }
        /// <summary>
        /// OK按钮计算目标数据的K-T变换结果
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void button1_Click(object sender, EventArgs e)
        {
            filename = listBox1.Text;
            GetDataByFilename gdbf = new GetDataByFilename();
            int pos = gdbf.getnumber(Form1.boduan, filename);

            if (listBox1.Text == "")
            {
                MessageBox.Show("无有效数据!");
                this.Close();
            }
            else if (Form1.boduan[pos].bands < 6)
            {
                MessageBox.Show("文件波段不满6!");
            }
            else
            {
                /// <summary>
                ///K-T变换结果数据流初始化
                /// </summary>
                read rd = new read();
                //进行K_T变换
                /// <summary>
                ///K-T变换计算,数据传递
                /// <summary>

                K_Tchange ktc = new K_Tchange(pos);

                rd           = ktc.GetResult();
                rd.Bandsname = new string[3];

                rd.Bandsname[0] = "Brightness" + "(" + filename + ")";
                rd.Bandsname[1] = "Greenness" + "(" + filename + ")";
                rd.Bandsname[2] = "Third" + "(" + filename + ")";
                if (textBox1.Text == "")
                {
                    rd.FileName = "KT";
                }
                else
                {
                    rd.FileName = textBox1.Text;
                }

                /// <summary>
                ///静态窗口available打开,将结果加入静态数据流泛型中
                /// <summary>
                Form1.abl.readmore.Add(rd);
                Form1.abl.PATH = rd.FileName;
                Form1.boduan.Add(rd);
                Form1.abl.Form_Load(sender, e);
                Form1.abl.Show();


                this.Close();
            }
        }
Example #3
0
        public RichTextBox gethdr(string filename)
        {
            GetDataByFilename gdbf = new GetDataByFilename();
            int record             = gdbf.getnumber(Form1.boduan, filename);

            richTextBox1.Text += "Name:" + "\t" + Form1.boduan[record].FileName + "\r\n";
            richTextBox1.Text += "Columns:" + "\t" + Form1.boduan[record].ColumnCounts + "\r\n";
            richTextBox1.Text += "Lines:" + "\t" + Form1.boduan[record].LineCounts + "\r\n";
            richTextBox1.Text += "bands:" + "\t" + Form1.boduan[record].bands + "\r\n";
            richTextBox1.Text += "DataType:" + "\t" + Form1.boduan[record].DataType + "\r\n";
            return(richTextBox1);
        }
        /// <summary>
        /// 执行HSI转RGB操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (listBoxControl1.Text != "")
            {
                /// <summary>
                /// 创建新数据流
                /// <summary>
                read rd = new read();
                /// <summary>
                /// 索引参与运算数据
                /// <summary>
                GetDataByFilename gdbf = new GetDataByFilename();
                int      N             = gdbf.getnumber(Form1.boduan, listBoxControl1.Text);
                HSIToRGB HtR           = new HSIToRGB(N);
                if (!HtR.isHSI)
                {
                    MessageBox.Show("不是HSI数据!");
                    return;
                }
                rd = HtR.Getresult();
                if (textEdit1.Text == "")
                {
                    rd.FileName = "RGB";
                }
                else
                {
                    rd.FileName = textEdit1.Text;
                }

                rd.Bandsname[0] = "Rband";
                rd.Bandsname[1] = "Gband";
                rd.Bandsname[2] = "Bband";
                /// <summary>
                /// 结果图像压入静态数据流
                /// <summary>
                Form1.boduan.Add(rd);
                Form1.abl.readmore.Add(rd);
                /// <summary>
                /// availablebandlist中显示结果数据
                /// <summary>
                Form1.abl.PATH = rd.FileName;
                Form1.abl.Form_Load(sender, e);
                this.Close();
            }
            else
            {
                MessageBox.Show("请选择数据!");
            }
        }
 private void Save_Click(object sender, EventArgs e)
 {
     if (treeView1.SelectedNode.Parent == null)
     {
         GetDataByFilename gdbf = new GetDataByFilename();
         int            i       = gdbf.getnumber(Form1.boduan, treeView1.SelectedNode.Text);
         SaveFileDialog sfd     = new SaveFileDialog();
         sfd.Filter = null;
         if (sfd.ShowDialog() == DialogResult.OK)
         {
             SaveFile sf = new SaveFile(Form1.boduan[i], sfd.FileName, Form1.boduan[i].DataType);
             sf.SaveDataF(); sf.Savehdr();
         }
     }
 }
        /// <summary>
        /// 进行分类操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (listBoxControl1.Text != "")
            {
                if (spinEdit1.Text == "")
                {
                    MessageBox.Show("请选择分类个数!");
                    return;
                }
                /// <summary>
                /// 创建新数据流
                /// <summary>
                read rd = new read();
                /// <summary>
                /// 索引参与运算数据
                /// <summary>
                GetDataByFilename gdbf = new GetDataByFilename();
                int   N  = gdbf.getnumber(Form1.boduan, listBoxControl1.Text);
                Kmean Km = new Kmean(N, Convert.ToInt16(spinEdit1.Text), 7);
                rd = Km.GetResult();
                if (textEdit1.Text == "")
                {
                    rd.FileName = "classFile";
                }
                else
                {
                    rd.FileName = textEdit1.Text;
                }

                rd.Bandsname    = new string[1];
                rd.Bandsname[0] = "band1";


                Form1.boduan.Add(rd);
                Form1.abl.readmore.Add(rd);
                Form1.abl.PATH = rd.FileName;
                Form1.abl.Form_Load(sender, e);
                Form1.abl.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("请选择数据!");
                this.Close();
            }
        }
Example #7
0
        /// <summary>
        /// 传递数据至image stastics窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            /// </summary>
            /// 根据文件名选择数据
            /// </summary>
            if (listBox1.Text == "")
            {
                MessageBox.Show("请选择数据!");
                return;
            }
            Imagestatistics imagsta = new Imagestatistics();

            imagsta.FileName = listBox1.SelectedItem.ToString();
            GetDataByFilename gdb = new GetDataByFilename();
            int DataNumber        = gdb.getnumber(Form1.boduan, imagsta.FileName);

            /// </summary>
            /// imagsta实例窗体数据初始化和赋值
            /// </summary>
            imagsta.LineCounts   = Form1.boduan[DataNumber].LineCounts;
            imagsta.ColumnCounts = Form1.boduan[DataNumber].ColumnCounts;
            imagsta.bands        = Form1.boduan[DataNumber].bands;
            //imagsta.DataType = Form1.boduan[DataNumber].DataType;
            imagsta.Interleave = Form1.boduan[DataNumber].Interleave;
            imagsta.BandsData  = new int[imagsta.bands, imagsta.ColumnCounts *imagsta.LineCounts];
            imagsta.BandsDataD = new double[imagsta.bands, imagsta.ColumnCounts *imagsta.LineCounts];
            imagsta.showdata   = new int[imagsta.bands, imagsta.ColumnCounts *imagsta.LineCounts];
            for (int i = 0; i < imagsta.bands; i++)
            {
                for (int j = 0; j < imagsta.ColumnCounts * imagsta.LineCounts; j++)
                {
                    imagsta.BandsData[i, j]  = Form1.boduan[DataNumber].BandsData[i, j];
                    imagsta.BandsDataD[i, j] = Form1.boduan[DataNumber].BandsDataD[i, j];
                }
            }

            /// </summary>
            /// 生成0-255范围像素数据,用于联合直方图和共生矩阵
            /// </summary>
            imagestretch ims = new imagestretch(imagsta.ColumnCounts, imagsta.LineCounts, imagsta.bands);

            ims.LinearShow(imagsta.showdata, imagsta.BandsDataD);
            imagsta.Show();
            this.Close();
        }
        /// <summary>
        /// 增加节点(文件名为父节点,波段名为子节点)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Form_Load(object sender, EventArgs e)
        {
            TreeNode root = new TreeNode();

            root.Text = Path.GetFileName(PATH);
            treeView1.Nodes.Add(root);
            //获取单图像数据编号
            GetDataByFilename gdb = new GetDataByFilename();
            int time = gdb.getnumber(readmore, root.Text);

            for (int i = 0; i < readmore[time].bands; i++)
            {
                TreeNode leave = new TreeNode(readmore[time].Bandsname[i]);
                //leave.Text = readmore[time].Bandsname[i];
                root.Nodes.Add(leave);
            }
            panel1.Show();
            radioButton1.Checked = true;
            panel2.Hide();
            panel2.Location = panel1.Location;
        }
Example #9
0
        /// <summary>
        /// 进行滤波操作!
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (listBoxControl1.Text != "" && listBoxControl2.Text != "")
            {
                /// <summary>
                /// 创建新数据流
                /// <summary>
                read rd = new read();
                /// <summary>
                /// 索引参与运算数据
                /// <summary>
                GetDataByFilename gdbf = new GetDataByFilename();
                int N = gdbf.getnumber(Form1.boduan, listBoxControl1.Text);

                if (comboBox1.Text == "Smoothing")
                {
                    /// <summary>
                    /// 梯度倒数加权平均
                    /// <summary>
                    if (listBoxControl2.Text == "Gradient Inverse Weight")
                    {
                        GradientInverseWeight giw = new GradientInverseWeight(Form1.boduan[N].ColumnCounts, Form1.boduan[N].LineCounts, Form1.boduan[N].bands);
                        giw.Gradient(Form1.boduan[N].BandsDataD);
                        rd = giw.GetResult();
                        if (textEdit1.Text == "")
                        {
                            rd.FileName = "GradientInverseWeight";
                        }
                        else
                        {
                            rd.FileName = textEdit1.Text;
                        }

                        for (int i = 0; i < rd.bands; i++)
                        {
                            rd.Bandsname[i] = "GIW: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                        }
                    }
                    /// <summary>
                    /// 选择式掩模平滑
                    /// <summary>
                    else if (listBoxControl2.Text == "ChooseMask")
                    {
                        ChooseMask cm = new ChooseMask(Form1.boduan[N].ColumnCounts, Form1.boduan[N].LineCounts, Form1.boduan[N].bands);
                        cm.ChoseMaskPerf(Form1.boduan[N].BandsDataD);
                        rd = cm.GetResult();
                        if (textEdit1.Text == "")
                        {
                            rd.FileName = "ChooseMask";
                        }
                        else
                        {
                            rd.FileName = textEdit1.Text;
                        }

                        for (int i = 0; i < rd.bands; i++)
                        {
                            rd.Bandsname[i] = "CM: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                        }
                    }
                    /// <summary>
                    /// 均值滤波
                    /// <summary>
                    else if (listBoxControl2.Text == "Average")
                    {
                        Average_Median am = new Average_Median(Form1.boduan[N].ColumnCounts, Form1.boduan[N].LineCounts, Form1.boduan[N].bands);
                        am.AverSmoothing(Form1.boduan[N].BandsDataD);
                        rd = am.GetResult();
                        if (textEdit1.Text == "")
                        {
                            rd.FileName = "AverageSmooth";
                        }
                        else
                        {
                            rd.FileName = textEdit1.Text;
                        }

                        for (int i = 0; i < rd.bands; i++)
                        {
                            rd.Bandsname[i] = "Aver: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                        }
                    }
                    /// <summary>
                    /// 中值滤波
                    /// <summary>
                    else if (listBoxControl2.Text == "Median")
                    {
                        Average_Median am = new Average_Median(Form1.boduan[N].ColumnCounts, Form1.boduan[N].LineCounts, Form1.boduan[N].bands);
                        am.MedianSmoothing(Form1.boduan[N].BandsDataD);
                        rd = am.GetResult();
                        if (textEdit1.Text == "")
                        {
                            rd.FileName = "MedianSmooth";
                        }
                        else
                        {
                            rd.FileName = textEdit1.Text;
                        }

                        for (int i = 0; i < rd.bands; i++)
                        {
                            rd.Bandsname[i] = "Median: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                        }
                    }
                    else if (listBoxControl2.Text == "Gass Low Pass")
                    {
                        GassLowPass glp = new GassLowPass(Form1.boduan[N].ColumnCounts, Form1.boduan[N].LineCounts, Form1.boduan[N].bands);
                        glp.GetGassValue(Form1.boduan[N].BandsDataD, 5, 1);
                        rd = glp.GetResult();
                        if (textEdit1.Text == "")
                        {
                            rd.FileName = "Gass Low Pass";
                        }
                        else
                        {
                            rd.FileName = textEdit1.Text;
                        }

                        for (int i = 0; i < rd.bands; i++)
                        {
                            rd.Bandsname[i] = "GLP: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                        }
                    }
                }
                else if (comboBox1.Text == "Sharpen")
                {
                    /// <summary>
                    /// 梯度数据
                    /// <summary>
                    read rd2 = new read();
                    if (listBoxControl2.Text == "Laplacian")
                    {
                        Laplacian lpc = new Laplacian(Form1.boduan[N].ColumnCounts, Form1.boduan[N].LineCounts, Form1.boduan[N].bands);
                        lpc.Lapl(Form1.boduan[N].BandsDataD);
                        /// <summary>
                        /// 结果赋值
                        /// <summary>
                        rd  = lpc.GetResult();
                        rd2 = lpc.GetGrad();



                        /// <summary>
                        /// 文件名
                        /// <summary>
                        if (textEdit1.Text == "")
                        {
                            rd.FileName  = "LaplacianR";
                            rd2.FileName = "LaplacianG";
                        }
                        else
                        {
                            rd.FileName  = textEdit1.Text;
                            rd2.FileName = textEdit1.Text + "_G";
                        }
                        /// <summary>
                        /// 波段名
                        /// <summary>
                        for (int i = 0; i < rd.bands; i++)
                        {
                            rd.Bandsname[i]  = "LpR: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                            rd2.Bandsname[i] = "LpG: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                        }
                        /// <summary>
                        /// 梯度图像压入静态数据流
                        /// <summary>
                        Form1.boduan.Add(rd2);
                        Form1.abl.readmore.Add(rd2);
                        /// <summary>
                        /// availablebandlist中显示梯度数据
                        /// <summary>
                        Form1.abl.PATH = rd2.FileName;
                        Form1.abl.Form_Load(sender, e);
                    }
                    if (listBoxControl2.Text == "Prewitt")
                    {
                        Prewitt_Sobel ps = new Prewitt_Sobel(Form1.boduan[N].ColumnCounts, Form1.boduan[N].LineCounts, Form1.boduan[N].bands);
                        ps.PrePer1(Form1.boduan[N].BandsDataD);
                        ps.PrePer2(Form1.boduan[N].BandsDataD);
                        /// <summary>
                        /// 结果赋值
                        /// <summary>
                        rd  = ps.GetGrad1();
                        rd2 = ps.GetGrad2();
                        /// <summary>
                        /// 文件名
                        /// <summary>
                        if (textEdit1.Text == "")
                        {
                            rd.FileName  = "PrewittGW";
                            rd2.FileName = "PrewittGV";
                        }
                        else
                        {
                            rd.FileName  = textEdit1.Text + "_GW";
                            rd2.FileName = textEdit1.Text + "_GV";
                        }
                        /// <summary>
                        /// 波段名
                        /// <summary>
                        for (int i = 0; i < rd.bands; i++)
                        {
                            rd.Bandsname[i]  = "PTGW: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                            rd2.Bandsname[i] = "PTGV: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                        }
                        /// <summary>
                        /// 梯度图像压入静态数据流
                        /// <summary>
                        Form1.boduan.Add(rd2);
                        Form1.abl.readmore.Add(rd2);
                        /// <summary>
                        /// availablebandlist中显示梯度数据
                        /// <summary>
                        Form1.abl.PATH = rd2.FileName;
                        Form1.abl.Form_Load(sender, e);
                    }
                    else if (listBoxControl2.Text == "Sobel")
                    {
                        Prewitt_Sobel ps = new Prewitt_Sobel(Form1.boduan[N].ColumnCounts, Form1.boduan[N].LineCounts, Form1.boduan[N].bands);
                        ps.SobPer1(Form1.boduan[N].BandsDataD);
                        ps.SobPer2(Form1.boduan[N].BandsDataD);
                        /// <summary>
                        /// 结果赋值
                        /// <summary>
                        rd  = ps.GetGrad1();
                        rd2 = ps.GetGrad2();
                        /// <summary>
                        /// 文件名
                        /// <summary>
                        if (textEdit1.Text == "")
                        {
                            rd.FileName  = "SobelGW";
                            rd2.FileName = "SobelGV";
                        }
                        else
                        {
                            rd.FileName  = textEdit1.Text + "_GW";
                            rd2.FileName = textEdit1.Text + "_GV";
                        }
                        /// <summary>
                        /// 波段名
                        /// <summary>
                        for (int i = 0; i < rd.bands; i++)
                        {
                            rd.Bandsname[i]  = "SLGW: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                            rd2.Bandsname[i] = "SLGV: " + "(" + Form1.boduan[N].Bandsname[i] + ")";
                        }
                        /// <summary>
                        /// 梯度图像压入静态数据流
                        /// <summary>
                        Form1.boduan.Add(rd2);
                        Form1.abl.readmore.Add(rd2);
                        /// <summary>
                        /// availablebandlist中显示梯度数据
                        /// <summary>
                        Form1.abl.PATH = rd2.FileName;
                        Form1.abl.Form_Load(sender, e);
                    }
                }
                /// <summary>
                /// 结果图像压入静态数据流
                /// <summary>
                Form1.boduan.Add(rd);
                Form1.abl.readmore.Add(rd);
                /// <summary>
                /// availablebandlist中显示结果数据
                /// <summary>
                Form1.abl.PATH = rd.FileName;
                Form1.abl.Form_Load(sender, e);
                this.Close();
            }
        }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            /// <summary>
            /// No Display 时创建imageview新实例
            /// <summary>
            if (comboBox1.Text == "No Display")
            {
                /// <summary>
                /// comboBox操作,类似envi
                /// <summary>
                //windowsnum++;
                comboBox1.Items.Add("Display #" + 1);
                comboBox1.SelectedItem = "Display #" + 1;
                comboBox1.Items.Remove("No Display");
                /// <summary>
                /// 定义新窗体
                /// <summary>
                imageview imv = new imageview("Display #" + 1);
                imv.Text = "Display #" + 1;
                /// <summary>
                /// 选择灰度(单波段)显示
                /// <summary>
                if (radioButton1.Checked)
                {
                    if (textBox1.Text != "")
                    {
                        /// <summary>
                        ///索引数据流,得到数据
                        /// <summary>
                        string pathmark = Path.GetFileName(textBox1.Text);

                        GetDataByFilename gdb = new GetDataByFilename();
                        int           i       = gdb.getnumber(readmore, pathmark);
                        GetBandByname gbn     = new GetBandByname();
                        int           single  = gbn.getnumber(readmore[i].Bandsname, this.textBox1.Text.Substring(0, this.textBox1.Text.IndexOf(pathmark) - 1)
                                                              , readmore[i].bands);
                        /// <summary>
                        /// imv实例中各项数据初始化
                        /// <summary>
                        imv.ColumnCounts = readmore[i].ColumnCounts;
                        imv.LineCounts   = readmore[i].LineCounts;
                        imv.bands        = 1;
                        imv.showdata     = new int[imv.bands, imv.ColumnCounts *imv.LineCounts];
                        imv.BandsDataD   = new double[imv.bands, imv.ColumnCounts *imv.LineCounts];
                        imv.bandstemp    = new int[imv.bands, imv.ColumnCounts *imv.LineCounts];
                        /// <summary>
                        ///原数据存储
                        /// <summary>
                        for (int j = 0; j < readmore[i].ColumnCounts * readmore[i].LineCounts; j++)
                        {
                            imv.BandsDataD[0, j] = readmore[i].BandsDataD[single, j];
                        }

                        imv.pictureBox1.Height = imv.LineCounts;
                        imv.pictureBox1.Width  = imv.ColumnCounts;

                        ///窗口状态初始化
                        imv.handleBopen();
                        /// <summary>
                        ///通过LinearShow方法,将原数据拉伸至0-255用于显示
                        /// <summary>
                        imagestretch images = new imagestretch(imv.ColumnCounts, imv.LineCounts, imv.bands);
                        //images.LinearShow(imv.showdata, imv.BandsDataD);
                        imv.showdata = images.TwoPercentStretch(imv.BandsDataD);
                        /// <summary>
                        ///窗口命名
                        /// <summary>
                        imv.Text = textBox1.Text;
                        /// <summary>
                        ///显示图像
                        /// <summary>
                        ImageShow ims = new ImageShow();
                        imv.pictureBox1.Refresh();
                        Bitmap map = new Bitmap(imv.pictureBox1.Width, imv.pictureBox1.Height);

                        ims.showimage(imv.showdata, imv.ColumnCounts, imv.LineCounts, imv.bands, map);

                        imv.pictureBox1.Image = map;

                        imv.Show();
                        imv.Visible = true;
                    }
                    else
                    {
                        MessageBox.Show("请选择波段!");
                    }
                }
                else if (radioButton2.Checked)
                {
                    if (textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "")
                    {
                        /// <summary>
                        ///从list数据流中按文件名索引数据。
                        /// <summary>
                        string            pathmark2 = Path.GetFileName(textBox2.Text);
                        string            pathmark3 = Path.GetFileName(textBox3.Text);
                        string            pathmark4 = Path.GetFileName(textBox4.Text);
                        GetDataByFilename gdb       = new GetDataByFilename();
                        int i2 = gdb.getnumber(readmore, pathmark2);
                        int i3 = gdb.getnumber(readmore, pathmark3);
                        int i4 = gdb.getnumber(readmore, pathmark4);
                        /// <summary>
                        /// 按波段名索引波段号
                        /// <summary>
                        GetBandByname gbn   = new GetBandByname();
                        int           Rband = gbn.getnumber(readmore[i2].Bandsname, this.textBox2.Text.Substring(0, this.textBox2.Text.IndexOf(pathmark2) - 1)
                                                            , readmore[i2].bands);
                        int Gband = gbn.getnumber(readmore[i3].Bandsname, this.textBox3.Text.Substring(0, this.textBox3.Text.IndexOf(pathmark3) - 1)
                                                  , readmore[i3].bands);
                        int Bband = gbn.getnumber(readmore[i4].Bandsname, this.textBox4.Text.Substring(0, this.textBox4.Text.IndexOf(pathmark4) - 1)
                                                  , readmore[i4].bands);
                        if (Form1.boduan[i2].ColumnCounts == Form1.boduan[i3].ColumnCounts &&
                            Form1.boduan[i2].ColumnCounts == Form1.boduan[i4].ColumnCounts &&
                            Form1.boduan[i2].LineCounts == Form1.boduan[i3].LineCounts &&
                            Form1.boduan[i2].LineCounts == Form1.boduan[i4].LineCounts)
                        {
                            /// <summary>
                            /// imv实例中各项数据初始化
                            /// <summary>
                            imv.LineCounts   = readmore[i2].LineCounts;
                            imv.ColumnCounts = readmore[i3].ColumnCounts;
                            imv.bands        = 3;
                            imv.showdata     = new int[imv.bands, imv.LineCounts *imv.ColumnCounts];
                            imv.BandsDataD   = new double[imv.bands, imv.ColumnCounts *imv.LineCounts];
                            /// <summary>
                            ///任意图像任意波段合成(数据传递)
                            /// <summary>
                            for (int j = 0; j < imv.ColumnCounts * imv.LineCounts; j++)
                            {
                                imv.BandsDataD[0, j] = readmore[i2].BandsDataD[Rband, j];
                            }

                            for (int j = 0; j < imv.ColumnCounts * imv.LineCounts; j++)
                            {
                                imv.BandsDataD[1, j] = readmore[i3].BandsDataD[Gband, j];
                            }

                            for (int j = 0; j < imv.ColumnCounts * imv.LineCounts; j++)
                            {
                                imv.BandsDataD[2, j] = readmore[i4].BandsDataD[Bband, j];
                            }

                            imv.pictureBox1.Height = imv.LineCounts;
                            imv.pictureBox1.Width  = imv.ColumnCounts;
                            ///窗口状态初始化
                            imv.handleBopen();
                            /// <summary>
                            ///通过LinearShow方法,将原数据拉伸至0-255用于显示
                            /// <summary>
                            imagestretch images = new imagestretch(imv.ColumnCounts, imv.LineCounts, imv.bands);
                            images.LinearShow(imv.showdata, imv.BandsDataD);
                            //imv.showdata = images.TwoPercentStretch(imv.BandsDataD);

                            /// <summary>
                            ///窗口命名
                            /// <summary>
                            imv.Text = textBox2.Text + "&" + textBox3.Text + "&" + textBox4.Text;
                            /// <summary>
                            ///显示图像
                            /// <summary>
                            imv.pictureBox1.Refresh();
                            ImageShow ims = new ImageShow();
                            Bitmap    map = new Bitmap(imv.pictureBox1.Width, imv.pictureBox1.Height);
                            ims.showimage(imv.showdata, imv.ColumnCounts, imv.LineCounts, imv.bands, map);


                            imv.pictureBox1.Image = map;

                            imv.Show();
                            imv.Visible = true;
                        }
                        else
                        {
                            MessageBox.Show("波段规格不匹配!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("请输入波段!");
                    }
                }
                /// <summary>
                /// imv实例加入Wins泛型中
                /// <summary>
                Wins.Add(imv);
            }
            /// <summary>
            ///对已存在的imageview窗体进行数据传递和操作
            /// <summary>
            else
            {
                /// <summary>
                /// 搜索窗口
                /// <summary>
                GetWinByName gwn    = new GetWinByName();
                int          WinNbr = gwn.GetWinN(Wins, comboBox1.Text);

                if (radioButton1.Checked)
                {
                    if (textBox1.Text != "")
                    {
                        string pathmark = Path.GetFileName(textBox1.Text);
                        /// <summary>
                        ///索引数据流,得到数据
                        /// <summary>
                        GetDataByFilename gdb = new GetDataByFilename();
                        int           i       = gdb.getnumber(readmore, pathmark);
                        GetBandByname gbn     = new GetBandByname();
                        int           single  = gbn.getnumber(readmore[i].Bandsname, this.textBox1.Text.Substring(0, this.textBox1.Text.IndexOf(pathmark) - 1)
                                                              , readmore[i].bands);
                        /// <summary>
                        /// imv实例中各项数据初始化
                        /// <summary>
                        Wins[WinNbr].ColumnCounts = readmore[i].ColumnCounts;
                        Wins[WinNbr].LineCounts   = readmore[i].LineCounts;
                        Wins[WinNbr].bands        = 1;
                        Wins[WinNbr].showdata     = new int[Wins[WinNbr].bands, Wins[WinNbr].ColumnCounts * Wins[WinNbr].LineCounts];
                        Wins[WinNbr].BandsDataD   = new double[Wins[WinNbr].bands, Wins[WinNbr].ColumnCounts * Wins[WinNbr].LineCounts];
                        /// <summary>
                        ///原数据存储
                        /// <summary>
                        for (int j = 0; j < readmore[i].ColumnCounts * readmore[i].LineCounts; j++)
                        {
                            Wins[WinNbr].BandsDataD[0, j] = readmore[i].BandsDataD[single, j];
                        }

                        Wins[WinNbr].pictureBox1.Height = Wins[WinNbr].LineCounts;
                        Wins[WinNbr].pictureBox1.Width  = Wins[WinNbr].ColumnCounts;

                        ///窗口状态初始化
                        Wins[WinNbr].handleBopen();
                        /// <summary>
                        ///通过LinearShow方法,将原数据拉伸至0-255用于显示
                        /// <summary>
                        imagestretch images = new imagestretch(Wins[WinNbr].ColumnCounts, Wins[WinNbr].LineCounts, Wins[WinNbr].bands);
                        //images.LinearShow(Wins[WinNbr].showdata, Wins[WinNbr].BandsDataD);
                        Wins[WinNbr].showdata = images.TwoPercentStretch(Wins[WinNbr].BandsDataD);
                        /// <summary>
                        /// 图像拉伸数据初始化和赋值
                        /// <summary>
                        BandpixelInitialize bpi = new BandpixelInitialize();
                        bpi.Initialization(out Wins[WinNbr].bandstemp, Wins[WinNbr].showdata, Wins[WinNbr].ColumnCounts
                                           , Wins[WinNbr].LineCounts, Wins[WinNbr].bands);
                        /// <summary>
                        ///窗口命名
                        /// <summary>
                        Wins[WinNbr].Text = textBox1.Text;
                        /// <summary>
                        ///显示图像
                        /// <summary>
                        ImageShow ims = new ImageShow();
                        //ims.showimage(bandints,ColumnCounts,LineCounts)
                        Wins[WinNbr].pictureBox1.Refresh();
                        Bitmap map = new Bitmap(Wins[WinNbr].pictureBox1.Width, Wins[WinNbr].pictureBox1.Height);

                        ims.showimage(Wins[WinNbr].showdata, Wins[WinNbr].ColumnCounts, Wins[WinNbr].LineCounts, Wins[WinNbr].bands, map);

                        Wins[WinNbr].pictureBox1.Image = map;

                        Wins[WinNbr].Show();
                        Wins[WinNbr].Visible = true;
                    }
                    else
                    {
                        MessageBox.Show("请输入波段!");
                    }
                }
                else if (radioButton2.Checked)
                {
                    if (textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "")
                    {
                        /// <summary>
                        ///从list数据流中按文件名索引数据。
                        /// <summary>
                        string            pathmark2 = Path.GetFileName(textBox2.Text);
                        string            pathmark3 = Path.GetFileName(textBox3.Text);
                        string            pathmark4 = Path.GetFileName(textBox4.Text);
                        GetDataByFilename gdb       = new GetDataByFilename();
                        int i2 = gdb.getnumber(readmore, pathmark2);
                        int i3 = gdb.getnumber(readmore, pathmark3);
                        int i4 = gdb.getnumber(readmore, pathmark4);
                        /// <summary>
                        /// 按波段名索引波段号
                        /// <summary>
                        GetBandByname gbn   = new GetBandByname();
                        int           Rband = gbn.getnumber(readmore[i2].Bandsname, this.textBox2.Text.Substring(0, this.textBox2.Text.IndexOf(pathmark2) - 1)
                                                            , readmore[i2].bands);
                        int Gband = gbn.getnumber(readmore[i3].Bandsname, this.textBox3.Text.Substring(0, this.textBox3.Text.IndexOf(pathmark3) - 1)
                                                  , readmore[i3].bands);
                        int Bband = gbn.getnumber(readmore[i4].Bandsname, this.textBox4.Text.Substring(0, this.textBox4.Text.IndexOf(pathmark4) - 1)
                                                  , readmore[i4].bands);
                        if (Form1.boduan[i2].ColumnCounts == Form1.boduan[i3].ColumnCounts &&
                            Form1.boduan[i2].ColumnCounts == Form1.boduan[i4].ColumnCounts &&
                            Form1.boduan[i2].LineCounts == Form1.boduan[i3].LineCounts &&
                            Form1.boduan[i2].LineCounts == Form1.boduan[i4].LineCounts)
                        {
                            /// <summary>
                            /// imv实例中各项数据初始化
                            /// <summary>
                            Wins[WinNbr].LineCounts   = readmore[i2].LineCounts;
                            Wins[WinNbr].ColumnCounts = readmore[i3].ColumnCounts;
                            Wins[WinNbr].bands        = 3;
                            Wins[WinNbr].showdata     = new int[3, Wins[WinNbr].LineCounts * Wins[WinNbr].ColumnCounts];
                            Wins[WinNbr].BandsDataD   = new double[3, Wins[WinNbr].LineCounts * Wins[WinNbr].ColumnCounts];
                            /// <summary>
                            ///任意图像任意波段合成(数据传递)
                            /// <summary>
                            for (int j = 0; j < Wins[WinNbr].ColumnCounts * Wins[WinNbr].LineCounts; j++)
                            {
                                Wins[WinNbr].BandsDataD[0, j] = readmore[i2].BandsDataD[Rband, j];
                            }

                            for (int j = 0; j < Wins[WinNbr].ColumnCounts * Wins[WinNbr].LineCounts; j++)
                            {
                                Wins[WinNbr].BandsDataD[1, j] = readmore[i3].BandsDataD[Gband, j];
                            }

                            for (int j = 0; j < Wins[WinNbr].ColumnCounts * Wins[WinNbr].LineCounts; j++)
                            {
                                Wins[WinNbr].BandsDataD[2, j] = readmore[i4].BandsDataD[Bband, j];
                            }

                            Wins[WinNbr].pictureBox1.Height = Wins[WinNbr].LineCounts;
                            Wins[WinNbr].pictureBox1.Width  = Wins[WinNbr].ColumnCounts;
                            ///窗口状态初始化
                            Wins[WinNbr].handleBopen();
                            /// <summary>
                            ///通过LinearShow方法,将原数据拉伸至0-255用于显示
                            /// <summary>
                            imagestretch images = new imagestretch(Wins[WinNbr].ColumnCounts, Wins[WinNbr].LineCounts, Wins[WinNbr].bands);
                            //images.LinearShow(Wins[WinNbr].showdata, Wins[WinNbr].BandsDataD);
                            Wins[WinNbr].showdata = images.TwoPercentStretch(Wins[WinNbr].BandsDataD);
                            /// <summary>
                            /// 图像拉伸数据初始化和赋值
                            /// <summary>
                            BandpixelInitialize bpi = new BandpixelInitialize();
                            bpi.Initialization(out Wins[WinNbr].bandstemp, Wins[WinNbr].showdata, Wins[WinNbr].ColumnCounts
                                               , Wins[WinNbr].LineCounts, Wins[WinNbr].bands);
                            /// <summary>
                            ///窗口命名
                            /// <summary>
                            Wins[WinNbr].Text = textBox2.Text + "&" + textBox3.Text + "&" + textBox4.Text;
                            /// <summary>
                            ///显示图像
                            /// <summary>
                            Wins[WinNbr].pictureBox1.Refresh();
                            ImageShow ims = new ImageShow();
                            Bitmap    map = new Bitmap(Wins[WinNbr].pictureBox1.Width, Wins[WinNbr].pictureBox1.Height);
                            ims.showimage(Wins[WinNbr].showdata, Wins[WinNbr].ColumnCounts, Wins[WinNbr].LineCounts, Wins[WinNbr].bands, map);


                            Wins[WinNbr].pictureBox1.Image = map;

                            Wins[WinNbr].Show();
                            Wins[WinNbr].Visible = true;
                        }
                        else
                        {
                            MessageBox.Show("波段规格不匹配!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("请输入波段!");
                    }
                }
            }
        }
        /// <summary>
        /// HSI转换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "")
            {
                /// <summary>
                ///从list数据流中按文件名索引数据。
                /// <summary>
                string            pathmark1 = Path.GetFileName(textBox1.Text);
                string            pathmark2 = Path.GetFileName(textBox2.Text);
                string            pathmark3 = Path.GetFileName(textBox3.Text);
                GetDataByFilename gdb       = new GetDataByFilename();
                int iR = gdb.getnumber(Form1.boduan, pathmark1);
                int iG = gdb.getnumber(Form1.boduan, pathmark2);
                int iB = gdb.getnumber(Form1.boduan, pathmark3);
                /// <summary>
                /// 按波段名索引波段号
                /// <summary>
                GetBandByname gbn   = new GetBandByname();
                int           Rband = gbn.getnumber(Form1.boduan[iR].Bandsname, this.textBox1.Text.Substring(0, this.textBox1.Text.IndexOf(pathmark1) - 1)
                                                    , Form1.boduan[iR].bands);
                int Gband = gbn.getnumber(Form1.boduan[iG].Bandsname, this.textBox2.Text.Substring(0, this.textBox2.Text.IndexOf(pathmark2) - 1)
                                          , Form1.boduan[iG].bands);
                int Bband = gbn.getnumber(Form1.boduan[iB].Bandsname, this.textBox3.Text.Substring(0, this.textBox3.Text.IndexOf(pathmark3) - 1)
                                          , Form1.boduan[iB].bands);
                if (Form1.boduan[iR].ColumnCounts == Form1.boduan[iG].ColumnCounts &&
                    Form1.boduan[iR].ColumnCounts == Form1.boduan[iB].ColumnCounts &&
                    Form1.boduan[iR].LineCounts == Form1.boduan[iG].LineCounts && Form1.boduan[iR].LineCounts == Form1.boduan[iB].LineCounts)
                {
                    read rd = new read();


                    /// <summary>
                    /// RGBtoHSI
                    /// <summary>
                    RGBToHSI rth = new RGBToHSI(iR, iG, iB, Rband, Gband, Bband, rd);
                    rd              = rth.GetResult();
                    rd.Bandsname    = new string[3];
                    rd.Bandsname[0] = "Hue" + "(" + Form1.boduan[iR].Bandsname[Rband] + ":" + pathmark1 + ")";
                    rd.Bandsname[1] = "Sat" + "(" + Form1.boduan[iG].Bandsname[Gband] + ":" + pathmark2 + ")";
                    rd.Bandsname[2] = "Iit" + "(" + Form1.boduan[iB].Bandsname[Bband] + ":" + pathmark3 + ")";

                    if (textBox4.Text == "")
                    {
                        rd.FileName = "HSI";
                    }
                    else
                    {
                        rd.FileName = textBox4.Text;
                    }

                    /// <summary>
                    ///静态窗口available打开,将结果加入静态数据流泛型中
                    /// <summary>
                    Form1.abl.readmore.Add(rd);
                    Form1.abl.PATH = rd.FileName;
                    Form1.boduan.Add(rd);
                    Form1.abl.Form_Load(sender, e);
                    Form1.abl.Show();


                    this.Close();
                }
                else
                {
                    MessageBox.Show("波段规格不匹配!");
                }
            }
            else
            {
                MessageBox.Show("无有效数据!");
            }
        }
Example #12
0
        /// <summary>
        /// 四则运算
        /// </summary>
        /// <returns>返回结果</returns>
        private double[] EvaluateExpression()
        {
            try
            {
                string           myExp = expression + "=";                   //表达式。。
                Stack <char>     optr  = new Stack <char>(myExp.Length);     //存放操作符栈。。
                Stack <double[]> opnd  = new Stack <double[]>(myExp.Length); //存放操作数组栈。。
                optr.Push('=');
                int      index = 0;                                          //字符索引。。
                char     c     = myExp.ToCharArray()[index++];               //读取每一个字符。。
                double[] num1, num2;
                while ((c != '=') || (optr.Peek() != '='))
                {
                    if (c == '"')
                    {
                        string band_File = "";
                        while (true)
                        {
                            if ((c = myExp.ToCharArray()[index++]) == '"')
                            {
                                if (band_File.IndexOf(":") == -1)
                                {
                                    //double[] temp = opnd.Pop();
                                    //int Length = temp.GetLength(0);
                                    //opnd.Push(temp);
                                    //double math = Convert.ToDouble(band_File);
                                    //temp = new double[Length];
                                    //for (int i = 0; i < temp.GetLength(0); i++)
                                    //    temp[i] = math;
                                    //opnd.Push(temp);
                                    //c = myExp.ToCharArray()[index++];
                                    //break;
                                }
                                else
                                {
                                    //索引数据
                                    string            FileName = Path.GetFileName(band_File);
                                    GetDataByFilename gdbf     = new GetDataByFilename();
                                    int           i            = gdbf.getnumber(Form1.boduan, FileName);
                                    string        bandname     = band_File.Substring(0, band_File.IndexOf(FileName) - 1);
                                    GetBandByname gbbn         = new GetBandByname();
                                    int           j            = gbbn.getnumber(Form1.boduan[i].Bandsname, bandname, Form1.boduan[i].bands);
                                    //初始化数据并赋值
                                    double[] temp = new double[Form1.boduan[i].ColumnCounts * Form1.boduan[i].LineCounts];
                                    for (int k = 0; k < Form1.boduan[i].ColumnCounts * Form1.boduan[i].LineCounts; k++)
                                    {
                                        temp[k] = Form1.boduan[i].BandsDataD[j, k];
                                    }
                                    ColumnCounts = Form1.boduan[i].ColumnCounts;
                                    LineCounts   = Form1.boduan[i].LineCounts;
                                    //将数据压入栈中
                                    opnd.Push(temp);
                                    c = myExp.ToCharArray()[index++];
                                    break;
                                }
                            }
                            band_File += c;
                        }
                    }
                    else if (c != '+' && c != '-' && c != '*' && c != '/' && c != '(' && c != ')' && c != '=')
                    {
                        string band_File = "";
                        band_File += c;
                        while (true)
                        {
                            if (index + 1 == myExp.Length)
                            {
                                break;
                            }

                            c = myExp.ToCharArray()[index++];
                            if (!judge(c))
                            {
                                break;
                            }

                            band_File += c;
                        }
                        double[] temp   = opnd.Pop();
                        int      Length = temp.GetLength(0);
                        opnd.Push(temp);
                        double math = Convert.ToDouble(band_File);
                        temp = new double[Length];
                        for (int i = 0; i < temp.GetLength(0); i++)
                        {
                            temp[i] = math;
                        }

                        opnd.Push(temp);
                        c = myExp.ToCharArray()[index++];
                    }
                    else
                    {
                        bool isJump = false;

                        switch (Precede(optr.Peek(), c))
                        {
                        case '<':
                            optr.Push(c);
                            if ((index + 1) == myExp.Length)
                            {
                                isExpressionRight = false;
                                isJump            = true;
                                break;
                            }
                            c = myExp.ToCharArray()[index++];
                            break;

                        case '=':
                            optr.Pop();
                            //if ((index + 1) == myExp.Length)
                            //{
                            //    isExpressionRight = false;
                            //    isJump = true;
                            //    break;
                            //}
                            c = myExp.ToCharArray()[index++];
                            break;

                        case '>':
                            num2 = opnd.Pop();
                            num1 = opnd.Pop();
                            opnd.Push(Operate(num1, optr.Pop(), num2));
                            if (!ishandled)
                            {
                                isJump = true;
                            }

                            break;

                        default:
                            break;
                        }
                        if (isJump)
                        {
                            break;
                        }
                    }
                }
                if (!isExpressionRight)
                {
                    double[] a = new double[100];
                }
                return(opnd.Pop());
            }
            catch (Exception)
            {
                double[] a = new double[100];
                return(a);
            }
        }