public RGBToHSI(int iR, int iG, int iB, int Rband, int Gband, int Bband, read rd) { this.rd = rd; /// <summary> /// rd各项数据初始化 /// <summary> this.rd.bands = 3; this.rd.ColumnCounts = Form1.boduan[iR].ColumnCounts; this.rd.LineCounts = Form1.boduan[iR].LineCounts; this.rd.DataType = 4; this.rd.BandsDataD = new double[3, rd.ColumnCounts *rd.LineCounts]; this.rd.BandsData = new int[3, rd.ColumnCounts *rd.LineCounts]; /// <summary> ///任意图像任意波段合成(数据传递) /// <summary> for (int j = 0; j < rd.ColumnCounts * rd.LineCounts; j++) { this.rd.BandsDataD[0, j] = Form1.boduan[iR].BandsDataD[Rband, j]; } for (int j = 0; j < rd.ColumnCounts * rd.LineCounts; j++) { this.rd.BandsDataD[1, j] = Form1.boduan[iG].BandsDataD[Gband, j]; } for (int j = 0; j < rd.ColumnCounts * rd.LineCounts; j++) { this.rd.BandsDataD[2, j] = Form1.boduan[iB].BandsDataD[Bband, j]; } //传入原始数据 this.BandsDataD = this.rd.BandsDataD; }
/// <summary> /// 构造函数 /// </summary> /// <param name="rd"></param> /// <param name="dataPATH"></param> /// <param name="DataType"></param> public SaveFile(read rd, string dataPATH, int DataType) { this.DataType = DataType; this.rd = rd; this.dataPATH = dataPATH; this.HdrPATH = dataPATH + ".hdr"; }
public Laplacian(int ColumnCounts, int LineCounts, int bands) { this.ColumnCounts = ColumnCounts; this.LineCounts = LineCounts; this.bands = bands; rd = new read(); rd2 = new read(); }
public GradientInverseWeight(int ColumnCounts, int LineCounts, int bands) { this.ColumnCounts = ColumnCounts; this.LineCounts = LineCounts; this.bands = bands; Result = new double[bands, ColumnCounts *LineCounts]; rd = new read(); }
/// <summary> /// 初始化 /// </summary> /// <param name="ColumnCounts"></param> /// <param name="LineCounts"></param> /// <param name="bands"></param> public Average_Median(int ColumnCounts, int LineCounts, int bands) { this.ColumnCounts = ColumnCounts; this.LineCounts = LineCounts; this.bands = bands; Result = new double[bands, ColumnCounts *LineCounts]; rd = new read(); }
/// <summary> /// 初始化 /// </summary> /// <param name="ColumnCounts"></param> /// <param name="LineCounts"></param> /// <param name="bands"></param> public GassLowPass(int ColumnCounts, int LineCounts, int bands) { this.ColumnCounts = ColumnCounts; this.LineCounts = LineCounts; this.bands = bands; Result = new double[bands, ColumnCounts *LineCounts]; rd = new read(); }
public ChooseMask(int ColumnCounts, int LineCounts, int bands) { this.ColumnCounts = ColumnCounts; this.LineCounts = LineCounts; this.bands = bands; Result = new double[bands, ColumnCounts *LineCounts]; rd = new read(); }
public Prewitt_Sobel(int ColumnCounts, int LineCounts, int bands) { //this.flag = flag; this.ColumnCounts = ColumnCounts; this.LineCounts = LineCounts; this.bands = bands; rd = new read(); rd2 = new read(); }
public K_Tchange(int pos) { this.pos = pos; this.ColumnCounts = Form1.boduan[pos].ColumnCounts; this.LineCounts = Form1.boduan[pos].LineCounts; this.bands = Form1.boduan[pos].bands; K_T_result = new double[3, ColumnCounts *LineCounts]; rd = new read(); }
/// <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(); } }
/// <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("请选择数据!"); } }
/// <summary> /// 进行波段运算 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "") { read rd = new read(); Calc cc = new Calc(textBox1.Text); rd = cc.GetResult(); if (!cc.isExpressionRight) { MessageBox.Show("表达式不合法!"); return; } if (cc.ishandled) { if (textBox3.Text == "") { rd.FileName = "BandMath"; } else { rd.FileName = textBox3.Text; } rd.Bandsname[0] = textBox1.Text.Replace('"', ' ').Trim(); /// <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("请输入表达式!"); } }
/// <summary> /// 读取待转文件信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void simpleButton1_Click(object sender, EventArgs e) { OpenFileDialog OFD = new OpenFileDialog(); OFD.Filter = null; if (OFD.ShowDialog() == DialogResult.OK) { string Path = OFD.FileName; readHdrPath = Path + ".hdr"; rd = new read(); rd.HDRread(readHdrPath); rd.Dataread(Path); textEdit2.Text = Path; } }
/// <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(); } }
public read GetResult() { read rd = new read(); rd.bands = 1; rd.Bandsname = new string[rd.bands]; rd.DataType = 4; double[] temp = EvaluateExpression(); rd.LineCounts = LineCounts; rd.ColumnCounts = ColumnCounts; rd.BandsDataD = new double[1, rd.ColumnCounts *rd.LineCounts]; rd.BandsData = new int[1, rd.ColumnCounts *rd.LineCounts]; for (int i = 0; i < rd.BandsDataD.GetLength(1); i++) { rd.BandsDataD[0, i] = temp[i]; rd.BandsData[0, i] = (int)rd.BandsDataD[0, i]; } return(rd); }
/// <summary> /// 获取结果 /// </summary> /// <returns></returns> public read GetResult() { read rd = new read(); rd.bands = 1; rd.ColumnCounts = ColumnCounts; rd.LineCounts = LineCounts; rd.DataType = 4; double[] temp = operate(); rd.BandsDataD = new double[rd.bands, rd.ColumnCounts *rd.LineCounts]; rd.BandsData = new int[rd.bands, rd.ColumnCounts *rd.LineCounts]; for (int i = 0; i < rd.bands; i++) { for (int j = 0; j < ColumnCounts * LineCounts; j++) { rd.BandsDataD[i, j] = temp[j]; rd.BandsData[i, j] = (int)rd.BandsDataD[i, j]; } } return(rd); }
public read Getresult() { read rd1 = new read(); rd1.ColumnCounts = this.ColumnCounts; rd1.LineCounts = this.LineCounts; rd1.bands = 3; rd1.BandsDataD = evaluateRGB(); rd1.Bandsname = new string[rd.bands]; rd1.BandsData = new int[rd.bands, ColumnCounts *LineCounts]; for (int i = 0; i < rd1.bands; i++) { for (int j = 0; j < ColumnCounts * LineCounts; j++) { rd1.BandsData[i, j] = (int)rd1.BandsDataD[i, j]; } } rd1.DataType = 4; return(rd1); }
/// <summary> /// 打开新文件作为数据传入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { /// </summary> /// 新文件文件读取 /// </summary> string dataPath = ""; string hdrPath = ""; Imagestatistics imagsta = new Imagestatistics(); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = null; if (ofd.ShowDialog() == DialogResult.OK) { dataPath = ofd.FileName; hdrPath = ofd.FileName + ".hdr"; } read rd = new read(); rd.HDRread(hdrPath); /// </summary> /// imagsta实例窗体数据初始化和赋值 /// </summary> imagsta.LineCounts = rd.LineCounts; imagsta.ColumnCounts = rd.ColumnCounts; imagsta.bands = rd.bands; //imagsta.DataType = rd.DataType; imagsta.Interleave = rd.Interleave; imagsta.BandsData = new int[imagsta.bands, imagsta.ColumnCounts *imagsta.LineCounts]; imagsta.BandsDataD = new double[imagsta.bands, imagsta.ColumnCounts *imagsta.LineCounts]; //Form1.abl.readmore.Add(rd); if (rd.Dataread(dataPath) == true) { MessageBox.Show("选择成功!"); } imagsta.BandsData = rd.BandsData; imagsta.BandsDataD = rd.BandsDataD; imagsta.Show(); this.Close(); }
private void OpenFile_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { OpenFileDialog OFD = new OpenFileDialog(); OFD.Filter = null; if (OFD.ShowDialog() == DialogResult.OK) { /// <summary> /// 数据读取 /// <summary> DataPath = OFD.FileName; string hdrPATH = DataPath + ".hdr"; read rd = new read(); rd.HDRread(hdrPATH); rd.Dataread(DataPath); /// <summary> /// 添加至数据流中 readmore.Add(rd); boduan.Add(rd); this.BandsData = rd.BandsData; abl.readmore.Add(rd); /// <summary> /// 数据标识传递 /// <summary> abl.PATH = DataPath; /// <summary> /// Form_Load方法添加新树节点 abl.Form_Load(sender, e); /// <summary> /// show /// <summary> abl.Show(); } }
/// <summary> /// 开始计算极差纹理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { orglpixel = new int[this.LineCounts, this.ColumnCounts]; int i = Convert.ToInt32(comboBox1.Text.Substring(4)) - 1; int meansize; int max, min; if (radioButton1.Checked) { meansize = 3; } else if (radioButton2.Checked) { meansize = 5; } else { meansize = 0; MessageBox.Show("请输入窗口大小!"); return; } for (int j = 0; j < LineCounts; j++) { for (int k = 0; k < ColumnCounts; k++) { orglpixel[j, k] = bandints[i, k + j * ColumnCounts]; } } for (int j = 0; j < LineCounts; j++) { for (int k = 0; k < ColumnCounts; k++) { max = min = orglpixel[j, k]; for (int p = -1; p < meansize - 1; p++) { for (int q = -1; q < meansize - 1; q++) { if ((j + p) >= 0 && (j + p) < LineCounts && (k + q) >= 0 && (k + q) < ColumnCounts) { if (orglpixel[j + p, k + q] > max) { max = orglpixel[j + p, k + q]; } if (orglpixel[j + p, k + q] < min) { min = orglpixel[j + p, k + q]; } } } } this.meanrange[j * ColumnCounts + k] = max - min; } } read rd = new read(); rd.bands = 1; rd.ColumnCounts = this.ColumnCounts; rd.LineCounts = this.LineCounts; rd.DataType = 4; rd.BandsDataD = new double[rd.bands, ColumnCounts *LineCounts]; rd.Bandsname = new string[1]; rd.BandsData = new int[rd.bands, ColumnCounts *LineCounts]; for (int j = 0; j < ColumnCounts * LineCounts; j++) { rd.BandsDataD[0, j] = this.meanrange[j]; rd.BandsData[0, j] = (int)rd.BandsDataD[0, j]; } rd.Bandsname[0] = "band" + (i + 1); rd.FileName = "rangeTexture"; 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(); }
/// <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(); } }
/// <summary> /// 存储窗口数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e) { read rd = new read(); if (!isValue) { if (stretchtype == "") { for (int i = 0; i < bands; i++) { Bandsname[i] = "band" + (i + 1); } } else { for (int i = 0; i < bands; i++) { Bandsname[i] = stretchtype + ":" + "band" + (i + 1); } } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = null; if (sfd.ShowDialog() == DialogResult.OK) { rd.SaveData(ColumnCounts, LineCounts, bands, StretchTemp, Bandsname); SaveFile sf = new SaveFile(rd, sfd.FileName, 4); sf.SaveDataF(); sf.Savehdr(); MessageBox.Show("保存成功!"); rd.FileName = Path.GetFileNameWithoutExtension(sfd.FileName); rd.bands = bands; rd.ColumnCounts = ColumnCounts; rd.LineCounts = LineCounts; rd.Bandsname = Bandsname; rd.BandsDataD = StretchTemp; rd.BandsData = new int[bands, ColumnCounts *LineCounts]; for (int i = 0; i < bands; i++) { for (int j = 0; j < ColumnCounts * LineCounts; j++) { rd.BandsData[i, j] = (int)rd.BandsDataD[i, j]; } } Form1.boduan.Add(rd); Form1.abl.readmore.Add(rd); Form1.abl.PATH = rd.FileName; Form1.abl.Form_Load(sender, e); Form1.abl.Show(); } } else if (isValue) { for (int i = 0; i < bands; i++) { for (int j = 0; j < ColumnCounts * LineCounts; j++) { StretchTemp[i, j] = (double)bandstemp[i, j] / 255; } } for (int i = 0; i < bands; i++) { Bandsname[i] = "Binary" + ":" + "band" + (i + 1); } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = null; if (sfd.ShowDialog() == DialogResult.OK) { rd.SaveData(ColumnCounts, LineCounts, bands, StretchTemp, Bandsname); SaveFile sf = new SaveFile(rd, sfd.FileName, 1); sf.SaveDataF(); sf.Savehdr(); MessageBox.Show("保存成功!"); rd.FileName = Path.GetFileNameWithoutExtension(sfd.FileName); rd.bands = bands; rd.ColumnCounts = ColumnCounts; rd.LineCounts = LineCounts; rd.Bandsname = Bandsname; rd.BandsDataD = StretchTemp; rd.BandsData = new int[bands, ColumnCounts *LineCounts]; for (int i = 0; i < bands; i++) { for (int j = 0; j < ColumnCounts * LineCounts; j++) { rd.BandsData[i, j] = (int)rd.BandsDataD[i, j]; } } Form1.boduan.Add(rd); Form1.abl.readmore.Add(rd); Form1.abl.PATH = rd.FileName; Form1.abl.Form_Load(sender, e); Form1.abl.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("无有效数据!"); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="rd"></param> /// <param name="InterLeave"></param> /// <param name="OrginHDR"></param> public Write(read rd, string InterLeave, string OrginHDR) { this.rd = rd; this.InterLeave = InterLeave; this.OrginHDR = OrginHDR; }