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 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 BttnMinus_Click(object sender, EventArgs e) { imageStartIndex.X -= sizeClipedImage.Width / 4; imageStartIndex.Y -= sizeClipedImage.Height / 4; Int32 newwid = (Int32)(sizeClipedImage.Width * 1.5F); Int32 newhgt = (Int32)(sizeClipedImage.Height * 1.5F); 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; } 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 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); } } }
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 Pb_MouseUp(object sender, MouseEventArgs e) { 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)); //new Size(360, 311); 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)); } if (startPosImage.X + sizeClipedImage.Width > width) { startPosImage.X = width - sizeClipedImage.Width; } if (startPosImage.Y + sizeClipedImage.Height > height) { startPosImage.Y = height - sizeClipedImage.Height; } sizeClipedImage.Width = 20 * ((sizeClipedImage.Width + 10) / 20); // hússzal oszthatónak kell lennie !!?? actualiminRed = ClipImage(iminRed, startPosImage, sizeClipedImage, width, height); actualiminGreen = ClipImage(iminGreen, startPosImage, sizeClipedImage, width, height); actualiminBlue = ClipImage(iminBlue, 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 { 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; } 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); } }