• 大小: 23.29MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-23
  • 语言: C#
  • 标签: RS  image  Image  filter  geometric  

资源简介

基于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 < BufferWidth; i++)
                {
                    for (j = 0; j < BufferHeight; 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个文件信息

评论

共有 条评论