GIS数字图像处理.ppt

;数字图像的基本概念;数字图像的存储结构;数字图像的存储结构;遥感数字图像的存储结构;遥感数字图像的存储结构;遥感数字图像的存储结构;void Image :: InitImage( ) { ImageRows = ImageCols = 0; Pixel = NULL; } void Image :: DeleteImage( ) { if ( Pixel != NULL ) delete [ ] Pixel; };创建一个灰度数字图像: bool Image :: CreateImage( int Rows, int Cols, unsigned char Gray ) { DeleteImage( ); Pixel = new unsigned char[ Rows * Cols ]; if ( Pixel == NULL ) return false;; ImageRows = Rows; ImageCols = Cols; for ( int i = 0; i Rows; i ++ ) for ( int j = 0; j Cols; j ++ ) Pixel[ i * Cols + j ] = Gray; return true; };设置一个像素的灰度 void Image :: SetAPixel( int i, int j, unsigned char Gray ) { if ( i ImageRows j ImageCols ) Pixel [ i * ImageCols + j ] = Gray; };获取一个像素的灰度 unsigned char Image :: GetAPixel( int i, int j ) { if ( i ImageRows j ImageCols ) return Pixel [ i * ImageCols + j ]; };显示一个灰度图像 void Image :: ShowImage( int x, int y ) { for ( int i = 0; i ImageRows; i ++ ) for ( int j = 0; j ImageCols; j ++ ) { unsigned char gray = Pixel[ i * ImageCols + j ]; DrawPoint( x + j, ScrHeight - y - i, RGB( gray, gray, gray ) ); } } // ScrHeight:屏幕高度;遥感数字图像的存储结构;从图像文件中读入图像数据 bool Image :: LoadAnImage( char* FileName ) { // …… };BMP图像文件格式: 一个BMP图像文件一般分成4个部分: 位图文件头:BITMAPFILEHEADER; 位图信息头:BITMAPINFOHEADER; 调色板:Palette; 图像像素数据:Pixels.;位图文件头:BITMAPFILEHEADER Typedef struct tagBITMAPFILEHEADER { WORD bfType; // 0x424d 即“BM” DWORD bfSize; // 文件大小字节数 WORD bfReserved1, bfReserved2; DWORD bfOffBits; // 像素数据偏移字节 } BITMAPFILEHEADER;;位图信息头:BITMAPINFOHEADER typedef struct tagBITMAPINFOHEADER { DWORD biSize; // 该结构长度,40字节 LONG biWidth; // 图像宽度,单位是像素 LONG biHeight; // 图像高度,单位是像素 WORD biPlanes; // 1 WORD biBitCount; // 1,4,8,24 DWORD biCompression; // BI_RGB DWORD biSizeImage; // 位图字节数=宽*高 LONG biXPelsPerMeter; // 水平分辨率 LONG biYPelsPerMeter; // 垂直分辨率 DWORD biClrUsed; // 实际颜色数,0… DWORD biClrImportant; // 重要颜色数,0… } BITMAPINFOHEADER; ;调色板 typedef struct tagR

文档评论(0)

1亿VIP精品文档

相关文档