public Bitmap createRGB_gwr(Size ncolnrows, byte[] red, byte[] green, byte[] blue) { Bitmap bmp = new Bitmap(ncolnrows.Width, ncolnrows.Height, PixelFormat.Format24bppRgb); int res = (ncolnrows.Width) % 4; //Math.DivRem(4 - res, 4, out res); int stride = (ncolnrows.Width + res) * 3; byte[] byOut = new byte[stride * ncolnrows.Height]; Int32 ind = 0; for (int i = 0; i < ncolnrows.Height; i++) { ind += res; for (int j = 0; j < ncolnrows.Width; j++) { byte redb = red[i * ncolnrows.Width + j]; byte greenb = green[i * ncolnrows.Width + j]; byte blueb = blue[i * ncolnrows.Width + j]; byOut[ind] = blueb; ind++; byOut[ind] = greenb; ind++; byOut[ind] = redb; ind++; } } GeoImageTools imgTools = new GeoImageTools(); bmp = imgTools.ByteArrayToBitmap(byOut, ncolnrows.Width, ncolnrows.Height); return(bmp); }
private void cmbXaxis_SelectedIndexChanged(object sender, EventArgs e) { GeoImageTools gimt = new GeoImageTools(gida); band1 = gimt.getOneBandBytes(cmbXaxis.SelectedIndex); bandResult = new byte[band1.Length]; }
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; }
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 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) { if (chkListBands.CheckedItems.Count == 0) { return; } this.Cursor = Cursors.WaitCursor; List <int> lst4PCA = new List <int>(gida.Nbands); foreach (var item in chkListBands.CheckedItems) { lst4PCA.Add((int)item); } GeoImageTools gimt = new GeoImageTools(gida); StatMath sm = new StatMath(gida, gimt, GiwerDataFolder); double[,] corr = sm.computeCorrelationMatrix(lst4PCA); printCorrelationMatrix(corr, lst4PCA.Count); double[] pca = sm.PCA(lst4PCA, sm.EigenVectors(corr), cmbWhichPC.SelectedIndex); PCN = pca.Select(n => { return(Convert.ToByte(n)); }).ToArray(); this.Cursor = Cursors.Default; bttnComputePCs.Enabled = true; //this.DialogResult = DialogResult.OK; //this.Close(); }
private void lstBands_SelectedIndexChanged(object sender, EventArgs e) { imw.Dock = DockStyle.Fill; GeoImageTools GTools = new GeoImageTools(gida); currentBand = GTools.getOneBandBytes(lstBands.SelectedIndex); imw.DrawImage(gida, currentBand, colorpal); spec = new Point[gida.Nbands]; createSpectrum(cursorPosition); spectrum.displaySpectrum(spec, gida.Wavelength); spectrum.BringToFront(); }
private void BttnMinus_Click(object sender, EventArgs e) { byte[] clipedImage; imageStartIndex.X -= sizeClipedImage.Width / 4; imageStartIndex.Y -= sizeClipedImage.Height / 4; Int32 newwid = (int)(sizeClipedImage.Width * 1.2F); Int32 newhgt = (Int32)(sizeClipedImage.Height * 1.2F); if (newwid > gimda.Ncols) { newwid = gimda.Ncols; } if (newhgt > gimda.Nrows) { newhgt = gimda.Nrows; } sizeClipedImage = new Size((int)(newwid), (int)(newhgt)); if (imageStartIndex.X < 0) { imageStartIndex.X = 0; } if (imageStartIndex.Y < 0) { imageStartIndex.Y = 0; } if (imageStartIndex.X > gimda.Ncols - sizeClipedImage.Width) { imageStartIndex.X = gimda.Ncols - sizeClipedImage.Width; } if (imageStartIndex.Y > gimda.Nrows - sizeClipedImage.Height) { imageStartIndex.Y = gimda.Nrows - sizeClipedImage.Height; } if (!flagRGB) { clipedImage = ClipImage(imageIn, imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows); GeoImageTools gt = new GeoImageTools(gimda); pb.Image = gt.convertOneBandBytesto8bitBitmap(clipedImage, sizeClipedImage.Width, sizeClipedImage.Height, colorPal); actualImage = clipedImage; spectrum.Hide(); tsbttnSpectrum.Checked = false; bttnPlus.Checked = true; } else { ZoomOutImageRGB(imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows); GeoMultiBandMethods gmb = new GeoMultiBandMethods(); pb.Image = gmb.createRGB_gwr(sizeClipedImage, actualiminRed, actualiminGreen, actualiminBlue); } width = sizeClipedImage.Width; height = sizeClipedImage.Height; }
private void bttnSaveToGiwerFormat_Click(object sender, EventArgs e) { SaveFileDialog sf = new SaveFileDialog(); sf.Filter = "Giwer header|*.gwh"; if (sf.ShowDialog() == DialogResult.OK) { GeoImageTools gita = new GeoImageTools(imgDat); frmTextInput tbInput = new frmTextInput("Comment"); tbInput.ShowDialog(); string desc = tbInput.inpuText; gita.saveOneBandResultAsGiwerFormat(sf.FileName, currentBand, desc); } }
void AligningBands() // band aligning for all bands: Band0 - Band1, Band0 - Band2, Band0 - Band3, ... { shifts.Clear(); pbar.Minimum = 0; pbar.Maximum = lstFiles.Items.Count - 1; pbar.Step = 1; pbar.Value = 0; pbar.Visible = true; cropMargin = 100 * (int)(gimda.Nrows / 300); offset = (int)(cropMargin / 15); GeoImageTools gtools = new GeoImageTools(gimda); List <float> listOfDiffs; List <string> listOfInds; Point startp1 = new Point(gimda.Ncols / 2 - cropMargin / 2, gimda.Nrows / 2 - cropMargin / 2); string fname1 = currentFolder + "\\" + lstFiles.Items[0].ToString().Split('_')[1] + ".gwr"; byte[] fileToCombine1 = ClipImage(gtools.readGwrFile(fname1), startp1, new Size(cropMargin, cropMargin), gimda.Ncols, gimda.Nrows); Point startp2 = startp1; shifts.Add("0;0"); textBox1.Text = ""; for (int i = 1; i < lstFiles.Items.Count; i++) // computes differences between bands one after the other { pbar.PerformStep(); Application.DoEvents(); string fname2 = currentFolder + "\\" + lstFiles.Items[i].ToString().Split('_')[1] + ".gwr"; byte[] fileToCombine2 = gtools.readGwrFile(fname2); DifferenceOfShifts(fileToCombine1, fileToCombine2, startp2, out listOfDiffs, out listOfInds); float min; string minindex; getMin(listOfDiffs, listOfInds, out min, out minindex); shifts.Add(minindex); listOfDiffs.Clear(); listOfInds.Clear(); if (i > 1) { textBox1.AppendText(Environment.NewLine); } textBox1.AppendText("B0-B" + i + " -> shift: " + minindex); //textBox1.AppendText(Environment.NewLine + "difference: " + min.ToString("#.###")); textBox1.Visible = true; } pbar.Visible = false; string minmax = getShiftsMinMax(); recoverBands(minmax); MessageBox.Show("Align process completed"); }
private void lstFiles_SelectedIndexChanged(object sender, EventArgs e) { if (lstFiles.SelectedItem != null) { GeoImageTools gtools = new GeoImageTools(); string fn = currentFolder + @"\" + lstFiles.SelectedItem.ToString().Split('_')[1] + ".gwr"; byte[] by = gtools.readGwrFile(fn); imw.DrawImage(gimda, by, loadColorPalette(Application.StartupPath + "\\" + "default.cp")); panel1.Visible = true; } else { panel1.Visible = false; } }
public Bitmap getAnRGBBand(int whichBand) { string gwrFile = Path.GetDirectoryName(gida.FileName) + "\\" + Path.GetFileNameWithoutExtension(gida.FileName) + "\\" + whichBand + ".gwr"; byte[] byIn = File.ReadAllBytes(gwrFile); Bitmap bmp = new Bitmap(gida.Ncols, gida.Nrows, PixelFormat.Format24bppRgb); int res = (gida.Ncols) % 4; int Stride = (gida.Ncols + res) * 3; byte[] byOut = new byte[Stride * gida.Nrows]; Int32 ind = 0; byte redb = 0; byte greenb = 0; byte blueb = 0; for (int i = 0; i < gida.Nrows; i++) { for (int j = 0; j < gida.Ncols; j++) { if (whichBand == 0) { redb = byIn[i * gida.Ncols + j]; greenb = 0; blueb = 0; } if (whichBand == 1) { greenb = byIn[i * gida.Ncols + j]; redb = 0; blueb = 0; } if (whichBand == 2) { blueb = byIn[i * gida.Ncols + j]; redb = 0; greenb = 0; } byOut[ind] = blueb; ind++; byOut[ind] = greenb; ind++; byOut[ind] = redb; ind++; } ind += res; } GeoImageTools imgTools = new GeoImageTools(gida); bmp = imgTools.ByteArrayToBitmap(byOut, gida.Ncols, gida.Nrows); return(bmp); }
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 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; }
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; }
//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); }
//compute band shifts between im1 and im2 bands started at startpoint from -halfoffset to halfoffset void DifferenceOfShifts(byte[] im1, byte[] im2, Point startpoint, out List <float> lstDiffs, out List <string> lstInds) { lstDiffs = new List <float>(); lstInds = new List <string>(); Size sz = new Size(cropMargin, cropMargin); byte[] im3; // = new byte[cropMargin * cropMargin]; byte[] difference; // = new byte[im3.Length]; GeoImageTools gtools = new GeoImageTools(gimda); int halfoffset = offset / 2; for (Int32 i = -halfoffset; i < halfoffset; i++) { for (Int32 j = -halfoffset; j < halfoffset; j++) { im3 = ClipImage(im2, new Point(startpoint.X + j, startpoint.Y + i), sz, gimda.Ncols, gimda.Nrows); difference = gtools.combine2Images(GeoImageTools.OperationType.Minus, im1, im3); lstDiffs.Add(summa(difference)); lstInds.Add(j + ";" + i); } } }
private void bttnHisto_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(imgDat.Ncols, imgDat.Nrows); Histogram3 hist = new Histogram3(currentBand, System.IO.Path.GetFileName(imgDat.FileName)); GeoImageTools gmt = new GeoImageTools(); if (hist.ShowDialog() == DialogResult.OK) { GeoMultiBandMethods gm = new GeoMultiBandMethods(); currentBand = hist.HistogramEqualization(currentBand, hist.IntMin, hist.IntMax); if (imgDat.FileType == GeoImageData.fTypes.GWH) { iw.DrawImage(imgDat, currentBand, colPalette); //iw.InitImage(gmt.convertOneBandBytesto8bitBitmap(currentBand, imgDat.Ncols, imgDat.Nrows, colPalette)); //Bitmap bm = gm.createRGB_gwr(imgDat, currentBand, currentBand, currentBand); //iw.loadImage(bm); } if (imgDat.FileType == GeoImageData.fTypes.BIL) { Bitmap bm = gm.createRGB_gwr(imgDat, currentBand, currentBand, currentBand); //iw.loadImage(bm); } } }
public StatMath(GeoImageData gid, GeoImageTools git, string gwrDatDir) { gida = gid; gito = git; GiwerDataFolder = gwrDatDir; }
private void cmbYaxis_SelectedIndexChanged(object sender, EventArgs e) { GeoImageTools gimt = new GeoImageTools(gida); band2 = gimt.getOneBandBytes(cmbYaxis.SelectedIndex); }
private void Pb_MouseUp(object sender, MouseEventArgs e) { //if (tsbttnSpectrum.Checked) return; byte[] clipedImage; if (tsbttnSpectrum.Checked) { Point loc = TranslateZoomMousePosition(e.Location, pb.Image); Point cur = new Point(imageStartIndex.X + loc.X, imageStartIndex.Y + loc.Y); if (((cur.X < 0) || (cur.Y < 0)) || ((cur.X > gimda.Ncols - 1) || (cur.Y > gimda.Nrows - 1))) { return; } Int32 bytePos = width * cur.Y + cur.X; spec = new Point[gimda.Nbands]; createSpectrum(bytePos); spectrum.displaySpectrum(spec, gimda.Wavelength); spectrum.showSpectrumAsTable(spec, gimda.Wavelength); this.Focus(); drawRectangleBool = false; return; } if (bttnPlus.Checked) // if zoom in mode is active { drawRectangleBool = false; startPosImage = TranslateZoomMousePosition(new Point(startx, starty), pb.Image); // compute start position in the image endPosImage = TranslateZoomMousePosition(e.Location, pb.Image); // compute end position in the image if (startPosImage.X == endPosImage.X || startPosImage.Y == endPosImage.Y) { return; } Int32 tmp = 0;; if (startPosImage.X > endPosImage.X) { tmp = startPosImage.X; startPosImage.X = endPosImage.X; endPosImage.X = tmp; } tmp = 0; if (startPosImage.Y > endPosImage.Y) { tmp = startPosImage.Y; startPosImage.Y = endPosImage.Y; endPosImage.Y = tmp; } float clipedImageAspect = (int)((float)(startPosImage.X - endPosImage.X) / (float)(startPosImage.Y - endPosImage.Y)); if (clipedImageAspect >= controlAspect) { sizeClipedImage = new Size((int)(float)((endPosImage.Y - startPosImage.Y) * controlAspect), endPosImage.Y - startPosImage.Y); } else { sizeClipedImage = new Size((int)(endPosImage.X - startPosImage.X), (int)(float)((endPosImage.X - startPosImage.X) / controlAspect + 0.5F)); } sizeClipedImage.Width = 20 * ((sizeClipedImage.Width + 10) / 20); if (startPosImage.X + sizeClipedImage.Width > width) { startPosImage.X = width - sizeClipedImage.Width; } if (startPosImage.Y + sizeClipedImage.Height > height) { startPosImage.Y = height - sizeClipedImage.Height; } if (!flagRGB) // if we are drawing a single band image { if (sizeClipedImage.Width <= 0 || sizeClipedImage.Height <= 0) { MessageBox.Show("Too small window to display"); return; } clipedImage = ClipImage(actualImage, startPosImage, sizeClipedImage, width, height); GeoImageTools gt = new GeoImageTools(gimda); pb.Image = gt.convertOneBandBytesto8bitBitmap(clipedImage, sizeClipedImage.Width, sizeClipedImage.Height, colorPal); actualImage = clipedImage; } else { //actualiminRed = ClipImage(actualiminRed, startPosImage, sizeClipedImage, width, height); //actualiminGreen = ClipImage(actualiminGreen, startPosImage, sizeClipedImage, width, height); //actualiminBlue = ClipImage(actualiminBlue, startPosImage, sizeClipedImage, width, height); //GeoMultiBandMethods gmb = new GeoMultiBandMethods(); //pb.Image = gmb.createRGB_gwr(sizeClipedImage, actualiminRed, actualiminGreen, actualiminBlue); } width = sizeClipedImage.Width; height = sizeClipedImage.Height; imageStartIndex = new Point(imageStartIndex.X + startPosImage.X, imageStartIndex.Y + startPosImage.Y); bttnPan.Enabled = true; } if (bttnPan.Checked) // if pan mode is active { sizeClipedImage.Width = 20 * ((sizeClipedImage.Width + 10) / 20); if ((width == gimda.Ncols) && (height == gimda.Nrows)) { return; } drawRectangleBool = false; Point loc = TranslateZoomMousePosition(e.Location, pb.Image); Point cur = new Point(imageStartIndex.X + loc.X, imageStartIndex.Y + loc.Y); //lb1.Text = "Pan point in image: (X:" + cur.X + " Y:" + cur.Y + ")"; imageStartIndex.X = cur.X - sizeClipedImage.Width / 2; if (imageStartIndex.X < 0) { imageStartIndex.X = 0; } if (imageStartIndex.X + sizeClipedImage.Width > gimda.Ncols) { imageStartIndex.X = gimda.Ncols - sizeClipedImage.Width; } imageStartIndex.Y = cur.Y - sizeClipedImage.Height / 2; if (imageStartIndex.Y < 0) { imageStartIndex.Y = 0; } if (imageStartIndex.Y + sizeClipedImage.Height > gimda.Nrows) { imageStartIndex.Y = gimda.Nrows - sizeClipedImage.Height; } if (!flagRGB) // if we are drawing a single band image { clipedImage = ClipImage(imageIn, imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows); GeoImageTools gt = new GeoImageTools(gimda); pb.Image = gt.convertOneBandBytesto8bitBitmap(clipedImage, sizeClipedImage.Width, sizeClipedImage.Height, colorPal); actualImage = clipedImage; } else// in case of RGB image { actualiminRed = ClipImage(iminRed, imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows); actualiminGreen = ClipImage(iminGreen, imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows); actualiminBlue = ClipImage(iminBlue, imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows); GeoMultiBandMethods gmb = new GeoMultiBandMethods(); pb.Image = gmb.createRGB_gwr(sizeClipedImage, actualiminRed, actualiminGreen, actualiminBlue); } } }
private void EditHeader_FormClosed(object sender, FormClosedEventArgs e) { GeoImageTools gtool = new GeoImageTools(gimData); gtool.saveHeader2Giwer(gimData.FileName); }