首页 平滑处理(Smoothing)

平滑处理(Smoothing)

举报
开通vip

平滑处理(Smoothing)平滑处理(Smoothing) 平滑处理(Smoothing) Image smoothing - neighbor request, the ship scatters average Author: C language implementation 2010-05-30 fourteen 25 minutes and 17 seconds | classification: image processing | subscription name Neighborhood averaging meth...

平滑处理(Smoothing)
平滑处理(Smoothing) 平滑处理(Smoothing) Image smoothing - neighbor request, the ship scatters average Author: C language implementation 2010-05-30 fourteen 25 minutes and 17 seconds | classification: image processing | subscription name Neighborhood averaging method is a simple method of smoothing spatial image, which has some effect on removing image noise. IFNDEF BMP_H_4_INCLUDED Definition BMP_H_4_INCLUDED Typedef unsigned short word Typedef unsigned long DWORD Typedef long; Bytes of typedef unsigned characters; The structure of the typedef tagBITMAPFILEHEADER {/ / bmfh Word bfType; DWORD bfSize; Text bfReserved1 Text bfReserved2 DWORD bfOffBits; } BITMAPFILEHEADER; Typedef structure tagBITMAPINFOHEADER {/ / bmih DWORD biSize; Long biWidth; LONG biHeight; Word biplane; WORD biBitCount; DWORD biCompression; DWORD member biSizeImage; Long biXPelsPerMeter; Long biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant; } BITMAPINFOHEADER; Typedef structure tagRGBQUAD {/ / Byte rgbq rgbBlue; Byte rgbGreen; Byte rgbRed; Byte rgbReserved; } RGBQUAD; Typedef structure tagBITMAPINFO { BITMAPINFOHEADER's bmiHeader; RGBQUAD bmiColors [1]; } BITMAPINFO; Includes Including Includes Including Including Including Includes "BMP_4.h"" BITMAPFILEHEADER bmfh, BITMAPINFOHEADER bmih,; Bytes * imgData; Invalid readData () INT ReadFileHeader (BITMAPFILEHEADER *); INT ReadInfoHeader (BITMAPINFOHEADER *); CreatePalette (RGBQUAD); ReadPixelData (bytes); Dragon GetLineBytes (INT, INT); Invalid NeighborAverage (double); SaveAsImage (CHAR *); The main part of interpretation () { Interpret me; Character saveasfilepath [256]; DWORD dwLineBytes; Double error; ReadData (); DwLineBytes = GetLineBytes (bmih.biWidth, bmih.biBitCount); Printf ("input error \ N \") ; Scanf functions ("%f" and errors); NeighborAverage (error); output (save as another path (e.g. D: / / poon.bmp) \ n); scanf function (`%s', saveasfilepath); I = SaveAsImage (saveasfilepath) if (I = = -1) {printf ("error: failed to save the image \ N");} return 0;} Invalid readData () { INT me, K, H DWORD dwLineBytes; I = ReadFileHeader (Bmfh); (I = = 0) {printf ("read file header successfully \ N");} K = ReadInfoHeader (bmih); If (K = = 0) { Printf (read info header success \ N \ ') ; } dwLineBytes = GetLineBytes (bmih.biWidth, bmih.biBitCount); imgData = (byte) malloc (dwLineBytes * bmih.biHeight * sizeof (byte)) H = ReadPixelData (imgData); if (H = = 0) {printf ("read pixel data \ N success!") } If K (I = = 0 & & 0 & & = = = = 0?) { Printf (read "success [N!)" in the data ; }} ReadFileHeader (BITMAPFILEHEADER * bmfh) { File * data file; Data file = FOPEN ("shuaige.bmp", "R" (FREAD (bmfh->); bfType sizeof (WORD), 1, data file) = 1) {printf ("please cannot read the file bfType. ` N '); FCLOSE (data file); returns -1;} (FREAD (bmfh->, bfSize, sizeof (DWORD), 1, data file) = 1) { Printf ("please do not read file header bfSize changes \ n"); FCLOSE (data file); Return -1; } (FREAD (bmfh->, bfReserved1, sizeof (WORD), 1, data file) = 1) { Printf (please cannot read the file header 'bfReserved1 \ N') ; FCLOSE (data file); Return -1; } (FREAD (bmfh->, bfReserved2, sizeof (WORD), 1, data file) = 1) { Printf (please cannot read the file header 'bfReserved2 \ N') ; FCLOSE (data file); Return -1; } (FREAD (bmfh->, bfOffBits, sizeof (DWORD), 1, data file) = 1) { Printf ("please do not read file header bfOffBits changes \ n"); FCLOSE (data file); Return -1; } Fclose (dataFile); Return 0; } ReadInfoHeader (BITMAPINFOHEADER * bmih) { File * data file; Data file = FOPEN ("shuaige.bmp", "R"); FSEEK (DATAFILE, 14, SEEK_SET); (FREAD (bmih->, biSize, sizeof (DWORD), 1, data file) = 1) { Printf ("please do not read the information header biSize changes \ n"); FCLOSE (data file); Return -1; } (FREAD (bmih->, biWidth, SIZEOF (long), 1, data file) = 1) { Printf ("please do not read the information header biWidth changes \ n"); FCLOSE (data file); Return -1; } (FREAD (bmih->, biHeight, SIZEOF (long), 1, data file) = 1) { "Printf" (unable to read the information header biHeight changes \ n '); FCLOSE (data file); Return -1; } If (FREAD, bmih->, WORD, SIZEOF, 1, data files) = 1) { Printf (unable to read information headers, wings \ N '); FCLOSE (data file); Return -1; } If (FREAD (bmih->, biBitCount, sizeof), 1, data file) = 1) { Printf ([header information cannot read biBitCount changes \ \ n '); FCLOSE (data file); Return -1; } If (FREAD (bmih->, biCompression, SIZEOF (DWORD), 1, data files), = 1) { Printf ("cannot read the biCompression change \ n" in the header of the information; FCLOSE (data file); Return -1; } (FREAD (bmih-> member, biSizeImage, sizeof (DWORD), 1, data file) = 1) { Printf ("please do not read the information header member biSizeImage changes \ n"); FCLOSE (data file); Return -1; } (FREAD (bmih->, biXPelsPerMeter, SIZEOF (long), 1, data file) = 1) { Printf ("please do not read the information header biXPelsPerMeter changes \ n"); FCLOSE (data file); Return -1; } (FREAD (bmih->, biYPelsPerMeter, SIZEOF (long), 1, data file) = 1) { Printf ("please do not read the information header biYPelsPerMeter changes \ n"); FCLOSE (data file); Return -1; } (FREAD (bmih->, biClrUsed, sizeof (DWORD), 1, data file) = 1) { Printf ([header information cannot be read 'biClrUsed \ N') ; FCLOSE (data file); Return -1; } If (FREAD, biClrImportant, sizeof (DWORD) data files, 1) = 1) bmih> { Printf (unable to read biClrImportant in info header \ N '); FCLOSE (data file); Return -1; } FCLOSE (data file); Return 0; } INT CreatePalette (PAL RGBQUAD []) { INT; (SIZEOF (PAL) / sizeof (RGBQUAD)! = 256) { Printf (the size of the palette must be 256 \ N '); Return -1; } (I = 0 <256; I + +) { PAL [me] rgbBlue = me;. PAL [me] rgbGreen = I;. PAL [me] rgbRed = me;. PAL [me] rgbReserved = 0;. } Return 0; } INT ReadPixelData (bytes * imgData) { Byte data File * data file, Double byte dwLineBytes,; DwLineBytes = GetLineBytes (bmih.biWidth, bmih.biBitCount); Data = = (BYTE *) malloc (dwLineBytes * bmih.biHeight * sizeof (byte)); Data file = cannot read pixel data \ n '); free (data); FCLOSE (data file); returns -1;} Memcpy (imgData, data, dwLineBytes * bmih.biHeight * sizeof (byte)); free (data); FCLOSE (data file); Return 0; } Long GetLineBytes (INT, imgWidth, INT, bitCount) { Returns (imgWidth *, bitCount, +31) / 32 * 4; } Invalid NeighborAverage (double error) { INT dwLineBytes INT NewdwLineBytes INT NewHeight; Bytes * NewData; Double gray; Me, J; NewData dwLineBytes = GetLineBytes (bmih.biWidth, bmih.biBitCount); NewdwLineBytes = dwLineBytes +2; NewHeight = bmih.biHeight +2 = (bytes) of malloc (NewdwLineBytes * NewHeight * sizeof (byte)); (I = 0;
本文档为【平滑处理(Smoothing)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
明明白白我的心
暂无简介~
格式:doc
大小:40KB
软件:Word
页数:15
分类:
上传时间:2018-04-10
浏览量:32