public void DrawImageRGB(GeoImageData gida, byte[] red, byte[] green, byte[] blue) // drawing the 24bits RGB byte array (red,green,blue) to the picture box (pb) { bttnMinus.Enabled = false; Clear(gida); this.Enabled = true; flagRGB = true; //gimda = gida; GeoImageTools gt = new GeoImageTools(gimda); width = gida.Ncols; height = gida.Nrows; imageAspect = (float)width / height; iminRed = red; iminGreen = green; iminBlue = blue; actualiminRed = red; actualiminGreen = green; actualiminBlue = blue; GeoMultiBandMethods gmb = new GeoMultiBandMethods(); pb.Image = gmb.createRGB_gwr(gida, iminRed, iminGreen, iminBlue); bttnPlus.Checked = true; bttnPan.Checked = false; pb.Cursor = Cursors.Default; }
public Bitmap createRGB_gwr(GeoImageData imgDat, byte[] red, byte[] green, byte[] blue) { Bitmap bmp = new Bitmap(imgDat.Ncols, imgDat.Nrows, PixelFormat.Format24bppRgb); int res = (imgDat.Ncols) % 4; //Math.DivRem(4 - res, 4, out res); int stride = (imgDat.Ncols + res) * 3; byte[] byOut = new byte[stride * imgDat.Nrows]; Int32 ind = 0; for (int i = 0; i < imgDat.Nrows; i++) { for (int j = 0; j < imgDat.Ncols; j++) { byte redb = red[i * imgDat.Ncols + j]; byte greenb = green[i * imgDat.Ncols + j]; byte blueb = blue[i * imgDat.Ncols + j]; byOut[ind] = blueb; ind++; byOut[ind] = greenb; ind++; byOut[ind] = redb; ind++; } ind += res; } GeoImageTools imgTools = new GeoImageTools(imgDat); bmp = imgTools.ByteArrayToBitmap(byOut, imgDat.Ncols, imgDat.Nrows); return(bmp); }
private void bttnOK_Click(object sender, EventArgs e) { colPalette = loadColorPalette(Application.StartupPath + "\\" + cmbColorPalettes.SelectedItem + ".cp"); NIRed = cmbInfraRed.SelectedIndex; Red = cmbRed.SelectedIndex; this.Cursor = Cursors.WaitCursor; panel1.Controls.Add(iw); iw.Dock = DockStyle.Fill; iw.Show(); GeoMultiBandMethods ndvi = new GeoMultiBandMethods(); string filesNamesNIR = GiwerDataFolder + "\\" + System.IO.Path.GetFileNameWithoutExtension(imgDat.FileName) + @"\" + NIRed + ".gwr"; string filesNamesRed = GiwerDataFolder + "\\" + System.IO.Path.GetFileNameWithoutExtension(imgDat.FileName) + @"\" + Red + ".gwr"; if (NIRed != -1 & Red != -1) { GeoImageData gima = new GeoImageData(); gima.FileName = GiwerDataFolder + "\\" + System.IO.Path.GetFileNameWithoutExtension(imgDat.FileName) + ".gwh"; GeoImageTools gmt = new GeoImageTools(gima); byte[] bnir = gmt.readGwrFile(filesNamesNIR); byte[] bred = gmt.readGwrFile(filesNamesRed); currentBand = ndvi.NDVI(bnir, bred); iw.DrawImage(gima, currentBand, colPalette); //iw.InitImage(gmt.convertOneBandBytesto8bitBitmap(currentBand,imgDat.Ncols,imgDat.Nrows,colPalette)); bttnHisto.Visible = true; bttnSaveAsImage.Visible = true; bttnSaveToGiwerFormat.Visible = true; } else { MessageBox.Show("Missing band! Two bands need to be selected"); } this.Cursor = Cursors.Default; }
public frmPCA(GeoImageData gd, string dirGWR) { InitializeComponent(); GiwerDataFolder = dirGWR; gida = gd; initCheckList(gida.Nbands); this.DialogResult = DialogResult.Cancel; }
public CrossPlot(GeoImageData gimda) { InitializeComponent(); gida = gimda; fillCmbBands(gida.Nbands); this.Text = "Cross-Plot for " + System.IO.Path.GetFileName(gida.FileName); this.DialogResult = DialogResult.Cancel; }
public frmCombineImages(GeoImageData gmd) { gimda = gmd; InitializeComponent(); fillCombo(); cmbBand1.SelectedIndex = 0; cmbBand2.SelectedIndex = 1; cmbOperationType.SelectedIndex = 1; }
public EditHeader(GeoImageData giDa) { InitializeComponent(); gimData = giDa; foreach (var prop in giDa.GetType().GetProperties()) { dgv.Rows.Add(prop.Name, prop.GetValue(giDa)); //tbH.AppendText( prop.Name + ", " + prop.GetValue(giDa, null)); } dgv.Columns[0].ReadOnly = true; dgv.Columns[1].ReadOnly = true; }
public void Clear(GeoImageData gd) // erase image of picture box { gimda = gd; pb.Image = null; lblCursorPosition.Text = ""; this.Enabled = false; imageStartIndex = new Point(0, 0); sizeClipedImage = new Size(gimda.Ncols, gimda.Nrows); width = gimda.Ncols; height = gimda.Nrows; }
public frmBandAlign(GeoImageData gd) { InitializeComponent(); bttnOK.Select(); gimda = gd; stLabFolder.Text = ""; fillList(); panel1.Controls.Add(imw); imw.Dock = DockStyle.Fill; imw.BackColor = Color.White; imw.Visible = true; imw.BringToFront(); }
public byte[] convertDDM2ByteArrayforDisplay(dtm dm, GeoImageData gd) { byte[] byOut = new byte[gd.Ncols * gd.Nrows]; Int32 ind = 0; float elevdiff = dm.ElevMax - dm.ElevMin; for (int i = 0; i < gd.Nrows; i++) { for (int j = 0; j < gd.Ncols; j++) { float val = 255F * ((dm.dem[j, i] - dm.ElevMin) / elevdiff); byOut[ind] = (byte)val; ind++; } } return(byOut); }
public frmNDVI(GeoImageData imgD, string gdf) { GiwerDataFolder = gdf; imgDat = imgD; InitializeComponent(); for (int i = 0; i < imgDat.Nbands; i++) { cmbInfraRed.Items.Add(i); cmbRed.Items.Add(i); } cmbRed.SelectedIndex = 2; loadAvailableCPFiles(); //colPalette = loadColorPalette(Application.StartupPath + "\\" + cmbColorPalettes.SelectedItem + ".cp"); if (imgDat.Nbands > 3) { cmbInfraRed.SelectedIndex = 3; } }
void recoverBands(string minmax) // minmax = minx; miny; maxx; maxy; minindex; maxindex { GeoImageTools gt = new GeoImageTools(gimda); GeoImageData gdOut = new GeoImageData(); gdOut = gimda; int widorig = gimda.Ncols; int hgtorig = gimda.Nrows; byte[] byin = new byte[widorig * hgtorig]; int maxindex = Convert.ToInt16(minmax.Split(';')[5]); int minindex = Convert.ToInt16(minmax.Split(';')[4]); int a = Math.Abs(Convert.ToInt16(shifts[minindex].Split(';')[0])); // get minx value from the shifts list int b = Math.Abs(Convert.ToInt16(shifts[maxindex].Split(';')[0])); // get maxx value from the shifts list int newwid = widorig - (a + b); int c = Math.Abs(Convert.ToInt16(shifts[minindex].Split(';')[1])); // get miny value from the shifts list int d = Math.Abs(Convert.ToInt16(shifts[maxindex].Split(';')[1])); // get maxy value from the shifts list int newhgt = hgtorig - (c + d); gdOut.Ncols = newwid; gdOut.Nrows = newhgt; gdOut.Nbits = 8; Size commonSize = new Size(newwid, newhgt); string fn = Path.GetDirectoryName(gimda.FileName) + "\\" + Path.GetFileNameWithoutExtension(gimda.FileName) + "_aligned.gwh"; GeoImageTools gtsave = new GeoImageTools(gdOut); gtsave.saveHeader2Giwer(fn); gdOut.FileName = fn; gtsave.saveHeader2Giwer(fn); for (int i = 0; i < lstFiles.Items.Count; i++) { int px = Math.Abs(Convert.ToInt16(shifts[i].Split(';')[0])); int py = Math.Abs(Convert.ToInt16(shifts[i].Split(';')[1])); //int px = Convert.ToInt16(shifts[maxindex].Split(';')[0]) - Convert.ToInt16(shifts[i].Split(';')[0]); //int py = Convert.ToInt16(shifts[maxindex].Split(';')[1]) - Convert.ToInt16(shifts[i].Split(';')[1]); Point startp = new Point(px, py); string fname = currentFolder + "\\" + lstFiles.Items[i].ToString().Split('_')[1] + ".gwr"; byin = gtsave.readGwrFile(fname); byte[] byOut = ClipImage(byin, startp, commonSize, widorig, hgtorig); string dirname = Path.GetDirectoryName(gdOut.FileName) + "\\" + Path.GetFileNameWithoutExtension(gdOut.FileName); gt.saveGivenBand2GiwerFormat(dirname, byOut, i, ""); } }
public frmSpectrumAnalysis(GeoImageData gimda, Int32[] colp) { InitializeComponent(); gida = gimda; colorpal = colp; fillListBands(); splitContainer1.Panel2.Controls.Add(imw); imw.Dock = DockStyle.Fill; GeoImageTools GTools = new GeoImageTools(gida); currentBand = GTools.getOneBandBytes(lstBands.SelectedIndex); imw.DrawImage(gida, currentBand, colp); spectrum.Show(); spectrum.BringToFront(); spectrum.Location = new Point(0, 0); //spec = new Point[gida.Nbands]; //createSpectrum(cursorPosition); //spectrum.displaySpectrum(spec); }
public void DrawImageDDM(GeoImageData gida, byte[] image, float[,] elevation, int[] colp) // drawing 8bits color palette image to picture box, which contains elevation based grey scale { elev = elevation; Clear(gida); this.Enabled = true; flagRGB = false; gimda = gida; GeoImageTools gt = new GeoImageTools(gimda); width = gimda.Ncols; height = gimda.Nrows; imageAspect = (float)width / height; imageIn = image; actualImage = image; pb.Image = gt.convertOneBandBytesto8bitBitmap(image, width, height, colp); colorPal = colp; bttnPlus.Checked = true; bttnPan.Checked = false; pb.Cursor = Cursors.Default; }
public void displayBandOnNewForm(GeoImageData gimd, byte[] byIn, Int32[] colp) { if (byIn != null) { System.Windows.Forms.Form frmImageDisplay = new System.Windows.Forms.Form(); ImageWindow imwindow = new ImageWindow(); int wd = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 3; int hgt = wd * gimd.Nrows / gimd.Ncols + (frmImageDisplay.Height - frmImageDisplay.ClientSize.Height); frmImageDisplay.Size = new Size(wd, hgt); frmImageDisplay.Controls.Add(imwindow); frmImageDisplay.Text = "Cross-plot selected pixels"; imwindow.Dock = System.Windows.Forms.DockStyle.Fill; imwindow.DrawImage(gimd, byIn, colp); frmImageDisplay.Show(); } else { System.Windows.Forms.MessageBox.Show("There is no image to display"); } }
public void DrawImage(GeoImageData gida, byte[] image, Int32[] colp) // drawing 8bits color palette image to picture box { Clear(gida); this.Enabled = true; flagRGB = false; gimda = gida; GeoImageTools gt = new GeoImageTools(gimda); width = gimda.Ncols; height = gimda.Nrows; imageAspect = (float)width / height; imageIn = image; //imIn2D = Onedim2dim(imageIn, width, height); actualImage = image; pb.Image = gt.convertOneBandBytesto8bitBitmap(image, width, height, colp); colorPal = colp; bttnPlus.Checked = true; bttnPan.Checked = false; pb.Cursor = Cursors.Default; }
//string DisplayCursorPosition; //string DisplayImageSize; //Boolean flagGWR; public RGBViewer(GeoImageData imgIn, string giwerDataFolder) { InitializeComponent(); imgDat = imgIn; imgTools = new GeoImageTools(imgDat); if (imgDat.Nbands < 2) { MessageBox.Show("You have too few bands, thus RGB creation is not possible", "Missing band", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } //this.Location = Giwer.Properties.Settings.Default.StartLocation; loadChecklist(imgDat.Nbands); gwrDataFolder = giwerDataFolder; frmConfig conf = new frmConfig(); //DisplayCursorPosition = conf.config["DisplayCursorPosition"]; //DisplayImageSize = conf.config["DisplayImageSize"]; imw = new ImageWindRGB(); this.WindowState = Properties.Settings.Default.RGBWindowState; this.Location = Properties.Settings.Default.RGBWindowStartLocation; this.Size = Properties.Settings.Default.RGBWindowSize; this.Text = "RGB creation for " + System.IO.Path.GetFileName(imgDat.FileName); }
public segmentationEdge(GeoImageData gimda) { gida = gimda; }
public GeoImageTools(GeoImageData gimDa) { gida = gimDa; }
public StatMath(GeoImageData gid) { gida = gid; }
public StatMath(GeoImageData gid, GeoImageTools git, string gwrDatDir) { gida = gid; gito = git; GiwerDataFolder = gwrDatDir; }