小波变换处理图像((课程设计)).docx
小波变换处理图像(课程设计) 数字图像处理课程设计报告 题目:小波变换处理图像 专业:信息与计算科学 学号: 组长: 指导教师: 成绩: 二一年六月二十六日 一、课程设计目的 小波分析是当前应用数学和工程学科中一个迅速发展的新领域,经过近10年的探索研究,重要的数学形式化体系已经建立,理论基础更加扎实。与Fourier 变换相比,小波变换是空间(时间)和频率的局部变换,因而能有效地从信号中提取信息。通过伸缩和平移等运算功能可对函数或信号进行多尺度的细化分析,解决了Fourier变换不能解决的许多困难问题。小波变换联系了应用数学、物理学、计算机科学、信号与信息处理、图像处理、地震勘探等多个学科。小波分析是一个新的数学分支,它是泛函分析、Fourier分析、样调分析、数值分析的完美结晶;小波分析是时间尺度分析和多分辨分析的一种新技术,它在信号分析、语音合成、图像识别、计算机视觉、数据压缩、地震勘探、大气与海洋波分析等方面的研究都取得了有科学意义和应用价值的成果。 二、课程设计要求 1、对知识点的掌握要求: 利用小波变换的基本原理在MATLAB环境下编写程序对静态图像进行分解并压缩,并观察分析其处理效果。 2、分组情况: 组长: 组员: 分工情况: :设计全过程的监督及协助和整个源程序代码的整理。 :负责小波变换的分解 :负责小波变化的重构算法 :负责编写MATLAB程序 :负责图像的压缩 3、课程设计内容 对知识点的掌握要求: 利用小波变换的基本原理在MATLAB环境下编写程序对静态图像进行分解并压缩,并观察分析其处理效果MATLAB是矩阵实验室(Matrix Laboratory)的简 称,它在数学类科技应用软件中在数值计算方面首屈一指。MATLAB可以进行矩阵运算、绘制函数和数据、 实现算法、创建用户界面、连接其它编程语言的程序等,主要应用于工程计算、控制设计、信号处理与通讯、图像处理、信号检测、金融建模设计与分析等领域。 本设计利用MATLAB工具箱中的Wavele Toolbox小波工具箱对图像进行小波变换。 三、课程设计实现步骤 构成了信号),(y x f 的二维正交小波分解系数(如图2.3所示), Z Z j j j j j j m n f W m n f W m n f W m n f S m n ?-= ),(),(),(),(3 211,.,) ,( 图2.3 二维正交小波分解系数 它们每一个都可被看做一幅图像,) ,(1m n f W j 给出了),(y x f 垂直方向的高 频分量的小波分解系数,) ,(3m n f W j 给出了),(y x f 水平方向的高频分量的小波 分解系数,) ,(2m n f W j 给出了),(y x f 对角方向高频分量的小波分解系数,f S J 给出了),(y x f 的低频分量的小波分解系数。由此可见,若用S J ,W j 1 ,W j 2 , W j 3分别表示) ,(m n f S j ,) ,(1m n f W j ,) ,(2m n f W j ,) ,(3m n f W j 经21亚抽 样后的变换系数(简称为子图像),则任一图像都可以分解为j=-J ,-1之间的3J+1个离散子图像:S J ,W j 1 ,W j 2 ,W j 3 其中S J 是原图像的一个近似, W i j (i=1,2,3;j=-J ,-1)则是图像在不同方向、不同分辨率下的细节; 如果原图像有N2个像素,则子图像S J ,W j 1,W j 2,W j 3分别有N i 2个像素, 因而分解后总的像素数N T 为 N N N N j j i J T 2 21 2 344 =+=-=- 下面的实例是基于二维小波分析对图像进行压缩。一个图像作小波分解后,可得到一系列不同分辨率的子图像,不同分辨率的子图像对应的频率是不相同的。高分辨率(即高频)子图像上大部分点都接近于0,越是高频这种现象越明显。对一个图像来说,表现一个图像最主要的部分是低频部分,所以一个最简单的压缩方法是利用小波分解,去掉图像的高频部分而只保留低频部分。 clc; clear all; a=imread('1.bmp'); X=rgb2gray(a); subplot(221);image(X);colormap(gray(256); title('原始图像'); axis square; c,s=wavedec2(X,2,'bior3.7'); ca1=appcoef2(c,s,'bior3.7',1); ch1=detcoef2('h',c,s,1); cv1=detcoef2('v',c,s,1); cd1=detcoef2('d',c,s,1); a1=wrcoef2('a',c,s,'bior3.7',1); h1=wrcoef2('h',c,s,'bior3.7',1); v1=wrcoef2('v',c,s,'bior3.7',1); d1=wrcoef2('d',c,s,'bior3.7',1); c1=a1,h1;v1,d1; subplot(222);image(c1); axis square title('分解后低频和高频信息'); ca1=appcoef2(c,s,'bior3.7',1); ca1=wcodemat(ca1,440,'mat',0); ca1=0.5*ca1; subplot(223);image(ca1);colormap(gray(256); title('第一次压缩图像'); axis square ca2=appcoef2(c,s,'bior3.7',2); ca2=wcodemat(ca2,440,'mat',0); ca2=0.25*ca2; subplot(224);image(ca2);colormap(gray(256); axis square; title('第二次压缩图像'); ifndef _BMPHEADER_H #define _BMPHEADER_H #pragma pack(1) typedef struct _BmpHeader char Identi2; /check DWORD ; DWORD Reserve1; DWORD DataOffset; /check DWORD HeaderSize; /check DWORD Width; /check DWORD Height; /check WORD Planes; WORD BitsPerPix; /check DWORD Compression; /check DWORD DataSize; DWORD hResolution; DWORD vResolution; DWORD Colors; /check DWORD ImportantColor; BmpHeader; /size if 54 typedef struct _Bmp BmpHeader Header; DWORD Palettes256; unsigned char Pix256256; Bmp; /size is 66614 /the in disk will be 66616 size Ndif Wavelet.cpp : Defines the class behaviors for the application. / #include "stdafx.h" #include "Wavelet.h" #include "MainFrm.h" #include "WaveletDoc.h" #include "WaveletView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_ char THIS_FILE = _FILE_; #endif / CWaveletApp BEGIN_MESSAGE_MAP(CWaveletApp, CWinApp) /AFX_MSG_MAP(CWaveletApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) / NOTE - the ClassWizard will add and remove mapping macros here. / DO NOT EDIT what you see in these blocks of generated code! /AFX_MSG_MAP / Standard document commands ON_COMMAND(ID_, CWinApp:On) ON_COMMAND(ID_, CWinApp:On) / Standard print setup command ON_COMMAND(ID_, CWinApp:On) END_MESSAGE_MAP() / CWaveletApp construction CWaveletApp:CWaveletApp() / TODO: add construction code here, / Place all significant initialization in InitInstance / The one and only CWaveletApp object CWaveletApp theApp; / CWaveletApp initialization BOOL CWaveletApp:InitInstance() AfxEnableControlContainer(); / Standard initialization / If you are not using these features and wish to reduce the size / of your final executable, you should remove from the following / the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); / Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); / Call this when linking to MFC statically #endif / Change the registry key under which our settings are stored. / TODO: You should modify this string to be something appropriate / such as the name of your company or organization. SetRegistryKey(_T("Local AppWizard-Generated Applications"); LoadStdPro(); / Load standard INI (including MRU) / Register the application's document templates. Document templates / serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CWaveletDoc), RUNTIME_CLASS(CMainFrame), / main SDI frame window RUNTIME_CLASS(CWaveletView); AddDocTemplate(pDocTemplate); / Parse command line for standard shell commands, DDE, CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); / Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo) return FALSE; / The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE;