資源簡介
基于C#寫的遙感圖像處理的課程設計程序,實現了影像讀取,影像濾波,影像幾何校正和影像分類,完美實現老師的要求。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?OSGeo.GDAL;
namespace?RS
{
????public?partial?class?Classification?:?Form
????{
????????public?Classification()
????????{
????????????InitializeComponent();
????????}
????????public?Bitmap?GetRGBImage(OSGeo.GDAL.Dataset?ds1?Rectangle?showRect1?int[]?bandlist1)
????????{
????????????int?imgWidth?=?ds1.RasterXSize;???//影像寬??
????????????int?imgHeight?=?ds1.RasterYSize;??//影像高??
????????????float?ImgRatio?=?imgWidth?/?(float)imgHeight;??//影像寬高比??
????????????//獲取顯示控件大小??
????????????int?BoxWidth?=?showRect1.Width;
????????????int?BoxHeight?=?showRect1.Height;
????????????float?BoxRatio?=?imgWidth?/?(float)imgHeight;??//顯示控件寬高比??
????????????//計算實際顯示區域大小,防止影像畸變顯示??
????????????int?BufferWidth?BufferHeight;
????????????if?(BoxRatio?>=?ImgRatio)
????????????{
????????????????BufferHeight?=?BoxHeight;
????????????????BufferWidth?=?(int)(BoxHeight?*?ImgRatio);
????????????}
????????????else
????????????{
????????????????BufferWidth?=?BoxWidth;
????????????????BufferHeight?=?(int)(BoxWidth?/?ImgRatio);
????????????}
????????????//構建位圖??
????????????Bitmap?bitmap?=?new?Bitmap(BufferWidth?BufferHeight
?????????????????????????????????????System.Drawing.Imaging.PixelFormat.Format24bppRgb);
????????????if?(bandlist1.Length?==?3)?????//RGB顯示??
????????????{
????????????????int[]?r?=?new?int[BufferWidth?*?BufferHeight];
????????????????Band?band1?=?ds1.GetRasterBand(bandlist1[0]);
????????????????band1.ReadRaster(0?0?imgWidth?imgHeight?r?BufferWidth?BufferHeight?0?0);??//讀取圖像到內存??
????????????????//為了顯示好看,進行最大最小值拉伸顯示??
????????????????double[]?maxandmin1?=?{?0?0?};
????????????????band1.ComputeRasterMinMax(maxandmin1?0);
????????????????int[]?g?=?new?int[BufferWidth?*?BufferHeight];
????????????????Band?band2?=?ds1.GetRasterBand(bandlist1[1]);
????????????????band2.ReadRaster(0?0?imgWidth?imgHeight?g?BufferWidth?BufferHeight?0?0);
????????????????double[]?maxandmin2?=?{?0?0?};
????????????????band2.ComputeRasterMinMax(maxandmin2?0);
????????????????int[]?b?=?new?int[BufferWidth?*?BufferHeight];
????????????????Band?band3?=?ds1.GetRasterBand(bandlist1[2]);
????????????????band3.ReadRaster(0?0?imgWidth?imgHeight?b?BufferWidth?BufferHeight?0?0);
????????????????double[]?maxandmin3?=?{?0?0?};
????????????????band3.ComputeRasterMinMax(maxandmin3?0);
????????????????int?i?j;
????????????????for?(i?=?0;?i?????????????????{
????????????????????for?(j?=?0;?j?????????????????????{
????????????????????????int?rVal?=?Convert.ToInt32(r[i?+?j?*?BufferWidth]);
????????????????????????rVal?=?(int)((rVal?-?maxandmin1[0])?/?(maxandmin1[1]?-?maxandmin1[0])?*?255);
????????????????????????int?gVal?=?Convert.ToInt32(g[i?+?j
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????929??2017-06-27?07:19??RS.sln
?????文件???????58368??2017-06-27?09:52??RS.v12.suo
?????文件?????1787904??2014-09-11?08:12??tif7.suo
?????文件???????55808??2017-06-27?07:20??tif7.v12.suo
?????目錄???????????0??2017-11-07?15:23??tif7\
?????目錄???????????0??2017-11-07?15:23??tif7\bin\
?????目錄???????????0??2017-11-07?15:23??tif7\bin\Debug\
?????文件?????1951744??2013-04-13?19:54??tif7\bin\Debug\cairo.dll
?????文件?????1152512??2010-10-25?14:52??tif7\bin\Debug\cfitsio.dll
?????文件????????8192??2014-05-08?11:34??tif7\bin\Debug\createdata.exe
?????文件???????65024??2012-01-01?13:31??tif7\bin\Debug\freexl.dll
?????文件??????121856??2010-10-25?14:54??tif7\bin\Debug\fribidi.dll
?????文件??????544768??2010-10-25?15:09??tif7\bin\Debug\ftgl.dll
?????文件????13827584??2014-05-08?11:29??tif7\bin\Debug\gdal111.dll
?????文件???????80384??2014-05-08?11:34??tif7\bin\Debug\gdal_csharp.dll
?????文件??????140800??2014-05-08?11:34??tif7\bin\Debug\gdal_wrap.dll
?????文件????????8192??2014-05-08?11:34??tif7\bin\Debug\GDALAdjustContrast.exe
?????文件????????5632??2014-05-08?11:34??tif7\bin\Debug\GDALColorTable.exe
?????文件???????19456??2014-05-08?11:34??tif7\bin\Debug\gdalconst_csharp.dll
?????文件???????12800??2014-05-08?11:34??tif7\bin\Debug\gdalconst_wrap.dll
?????文件????????5120??2014-05-08?11:34??tif7\bin\Debug\GDALCreateCopy.exe
?????文件????????7168??2014-05-08?11:34??tif7\bin\Debug\GDALDatasetRasterIO.exe
?????文件????????5120??2014-05-08?11:34??tif7\bin\Debug\GDALDatasetWrite.exe
?????文件????????5632??2014-05-08?11:34??tif7\bin\Debug\GDALGetHistogram.exe
?????文件????????9216??2014-05-08?11:34??tif7\bin\Debug\GDALInfo.exe
?????文件????????5632??2014-05-08?11:34??tif7\bin\Debug\GDALMemDataset.exe
?????文件????????6656??2014-05-08?11:34??tif7\bin\Debug\GDALOverviews.exe
?????文件????????8704??2014-05-08?11:34??tif7\bin\Debug\GDALRead.exe
?????文件????????8704??2014-05-08?11:34??tif7\bin\Debug\GDALReadDirect.exe
?????文件????????5120??2014-05-08?11:34??tif7\bin\Debug\GDALWrite.exe
?????文件?????1243648??2013-11-18?09:18??tif7\bin\Debug\geos.dll
............此處省略123個文件信息
評論
共有 條評論