数字图像处理实验指导书(英文版)
- 格式:pdf
- 大小:146.54 KB
- 文档页数:13
《数字图像处理》实验指导书前言本实验指导书可作为电子信息工程、通信工程、生物医学工程等专业《数字图像处理》课程的实验指导书。
实验指导书共提供了6个实验,要求在VB环境下实现。
实验名称与学时安排详见下表。
实验名称与学时安排表实验教学基本要求:1、在实验前,认真准备,熟悉和掌握相关实验内容的基本算法和程序设计技术。
2、根据实验目的和要求,按时认真完成各实验的上机操作。
3、实验结束后,要及时提交经调试正确的程序源代码、生成的可执行文件、实验报告书等文档。
实验一图象的读取保存及图像的二值化处理一、实验目的1、熟悉《数字图像处理》的实验平台。
2、了解VB对图像进行处理的基本方法。
3、熟悉彩色图像变成灰度图象以及灰度图像转换成二值图像的基本原理及处理过程。
二、实验准备1、复习彩色图像变成灰度图象以及灰度图像的二值化处理的基本原理。
2、阅读下列内容,了解VB对图像进行处理的基本方法。
(1)读取图像通过扫描仪、摄像机等输入计算机以.bmp、.ico或.wmf存储的图像文件,可用LoadPicture函数把图像文件装入窗体、图片框或图像框中,例如:picture1.picture=loadpicture(“c:\image\flower.bmp”)可以把路径为c:\image\flower.bmp的图像文件装入图片框picture1中。
为了使图片框的大小与图像相匹配,应将图片框的autosize属性设置为True。
(2)用Point方法获取彩色图像的颜色值Point方法的功能是获取图像上指定像素的颜色值。
格式为:Object.Point(x,y)其中,Object表示获取颜色的对象名,(x,y)为取得颜色的坐标位置。
Point 方法将指定位置的像素的颜色值返回一个长整形数。
例如,求图片框picture 1中图像在位置(x,y)的像素颜色值(col)时,可写为:dim col as longcol=picture1.Point(x,y)(3)用Pset方法画点Pset方法的功能是在指定的位置画一个指定颜色的点。
数字图像处理实验指导书赵泉华请各位同学在考试之前上交以下4个实验指导书实验一 MATLAB图像处理基本操作一、实验目的与要求1.熟悉及掌握在MATLAB 中能够处理哪些格式图像。
2.熟练掌握在MATLAB 中如何读取图像。
3.掌握如何利用MATLAB 来获取图像的大小、颜色、高度、宽度等等相关信息。
4.掌握如何在MATLAB 中按照指定要求存储一幅图像的方法。
5.图像间如何转化。
二、实验原理及知识点1、数字图像的表示和类别一幅图像可以被定义为一个二维函数f(x,y,其中x 和y 是空间(平面坐标,f 在任何坐标处(x,y处的振幅称为图像在该点的亮度。
灰度是用来表示黑白图像亮度的一个术语,而彩色图像是由单个二维图像组合形成的。
例如,在RGB 彩色系统中,一幅彩色图像是由三幅独立的分量图像(红、绿、蓝组成的。
因此,许多为黑白图像处理开发的技术适用于彩色图像处理,方法是分别处理三副独立的分量图像即可。
图像关于x 和y 坐标以及振幅连续。
要将这样的一幅图像转化为数字形式,就要求数字化坐标和振幅。
将坐标值数字化成为取样;将振幅数字化成为量化。
采样和量化的过程如图1所示。
因此,当f 的x 、y 分量和振幅都是有限且离散的量时,称该图像为数字图像。
作为MATLAB 基本数据类型的数值数组本身十分适于表达图像,矩阵的元素和图像的像素之间有着十分自然的对应关系。
图1 图像的采样和量化根据图像数据矩阵解释方法的不同,MA TLAB 把其处理为4类:亮度图像(Intensity images二值图像(Binary images索引图像(Indexed imagesRGB 图像(RGB images(1 亮度图像一幅亮度图像是一个数据矩阵,其归一化的取值表示亮度。
若亮度图像的像素都是uint8类或uint16类,则它们的整数值范围分别是[0,255]和[0,65536]。
若图像是double 类,则像素取值就是浮点数。
1.1图像点实验1.1.1图像反色实验实验目的1•熟悉视频显示程序的运行过程、控制过程,搞清数据处理、传输途径;2. 结合实例学习如何在视频显示程序中增加图像处理算法;3•了解图像反色的算法和用途;4•了解RF-5程序框架。
1.1.1.2实验内容1. 系统初始化;2. RF-5程序框架实现;3. 反色算法实现。
1.1.1.3实验背景知识将图像按象素进行求反,取得类似照相底片效果。
求反处理的图像与原始图“黑白颠倒”,可以看清原始图中灰黑区域的情况。
求反的图像一般用于数字图像的初步处理。
设D A表示输入图像的灰度,D B表示输出图像的灰度。
灰度变换方程为:D B=f(D A)=255-D A1.1.1.4程序简介1.1.1.4.1程序包含文件介绍1. main.c:实验的主程序。
系统使用到资源、CSL、BIOS以及任务初始化2. appData.c SCOM 模块初始化。
3. tskVideol nput .c:视频输入任务初始化及输入任务处理。
4. tskVideoOutput.c:视频输出任务初始化及输出任务处理。
5. DEC643.ge:系统初始化。
6. *h :程序使用的头文件。
7. *lib :程序使用的库文件。
8.li nk_dm642.cmd: 库文件连接命令文件。
9. VideoReverseloop2.tc:BIOS 配置文件。
10. VideoReverseloop2cfg.cmd DSP存储器及资源分配与程序各段的连接关系。
1.1.1.4.2程序架构简介实验例程采用RF-5 (参考设计框架5)实现视频的采集、处理及显示。
程序使用2个任务模块,视频采集任务以及视频处理输出任务。
系统流程图(一)初始化模块介绍1. 系统初始化模块功能介绍:初始化CSL以及BIOS设置64K 的CACHE ,并将其映射到EMIF 的CE0 及CE1 空间设置DMA 优先级序列,长度2. RF-5 模块初始化初始化RF-5 框架中用于内部单元传递消息的SCOM 模块3. 任务模块初始化启动任务存储空间分配及管理(二)任务模块介绍1. 输入任务输入任务从输入设备驱动程序获得视频图像,使用FVID (视频驱动程序)提供的FVID_exchange 函数调用输入设备按照4:2:2 格式获取一帧视频图像。
《数字图像处理》实验指导书(vc)实验指导书一、概述............................................................. .. (2)二、建立程序框架............................................................. ..............................................2三、建立图像类............................................................. ..................................................3四、定义图像文档实现图像读/写............................................................. ...................10五、实现图像显示............................................................. ............................................12六、建立图像处理类............................................................. ........................................18七、实现颜色处理功能............................................................. ....................................19(一)亮度处理............................................................. ...................................................19(二)对比度处理............................................................. ...............................................22(三)色阶处理............................................................. ...................................................24(四)伽马变换............................................................. ...................................................25(五)饱和度处理............................................................. ...............................................25(六)色调处理............................................................. ...................................................29八、实现几何变换功能............................................................. ....................................29(一)图像缩放............................................................. ...................................................29(二)旋转............................................................. ...........................................................31(三)水平镜像............................................................. ...................................................35(四)垂直镜像............................................................. ...................................................36(五)右转90度............................................................. .................................................36(六)左转90度............................................................. .................................................37(七)旋转180度............................................................. ...............................................37九、实现平滑锐化功能............................................................. (38)十、图像处理扩展编程............................................................. (38)一、概述实验项目:图像处理程序编程运行环境:Window某P/2000编程工具:ViualC++6.0主要内容:(1)建立程序框架,实现图像的读取、保存、显示;(2)编写颜色处理、几何变换、平滑锐化等图像处理代码,并实现其调用;(3)自行编写实现扩展的图像处理功能。
实验一Matlab图像处理工具箱的初步练习一. 实验目的1. 掌握有关数字图像处理的基本概念;2. 熟悉Matlab图像处理工具箱;3. 熟悉使用Matlab进行数字图像的读出和显示;4. 熟悉运用Matlab指令进行图像旋转和缩放变换。
二. 练习1. 文件的读入与显示(1) 运行Matlab。
(2) MATLAB窗口构成:在缺省的情况下,由三个窗口组成。
命令窗口(command window)、命令历史(command history)、工作空间(workspace)。
注意:缺省窗口的设置步骤为:MATLAB菜单/view选项/Desktop layout/default。
(3) 调入一个文件:i=imread('pout.tif');%注意:前面的“%”是用于注释的,不会被执行,只是说明这个语句的作用。
此时的i出现在什么窗口?是什么类型的变量?大小是多少?(4) 显示这幅图:imshow(i);(5) 将变量i转置成j,即j=i';显示j即imshow(j);%在胸前左侧花纹怎么会跑到右边的呢?举一个例子加以验证:设a=[1 2 3 4 5;6 7 8 9 10;11 12 13 14 15];b=a’;此时的b与a有什么区别?(6) 写入到一个新的图像文件'abc.tif'中,即imwrite(j,'abc.tif')。
(7) 清除变量命令:clear执行这个命令后,workspace窗口中的变量有没有?怎么验证?(8) 清除用户开设的窗口命令:close all(9) 调入图像文件'abc.tif'并显示。
问题:(1) 操作符“’”是图像的转置的意思,转置两次后,是否回到原图像?(2) 命令后的符号“;”所起的作用是什么?(3) 命令是否可以大写母?2. 灰度图像分别选择不同的灰度级(如2、4、16、64、128个)来显示同一幅图像(如testpat1.tif)。
EXPERIMENT 1 Showing and Orthogonal Transform of the Image一.Experimental purpose1.Master the orders of reading/writing and showing.2.Master the methods of transformations between the images of the differenttype.3.Master the methods of the orthogonal transform and the inverse transform.二.Be familiar with the common orders as follows:(skillful mastery)1.The orders of reading/writing and showing:imread read the image fileimfinfo read the related information of the image fileimwrite output the imageImshow show function of the standard imageImage establish and show a image objectImagesc adjust automatically the value field and show theimageColorbar show the color bartheimageMontage spliceImmovie turn the image sequence composed by the index colorimage into the cartoonSubimage show the multi-piece images in a graph windowzoom the image zoomwarp show the image in a curved face by the texturemapping2. The transform orders of image type:Dither image dither, turn the grey scale image into the binaryimage or dither the real color image into the index imageGray2ind turn the grey scale image into the index imageGrayslice turn the grey scale image into the index image by settingthe field valueIm2bw turn the real color, the index color and the grey scale imageinto the binary image by setting the luminance field valueInd2gray turn the index color image into the grey scale imageInd2rgb turn the index color image into the real color imageMat2gray turn the data matrix into the grey scale imageRgb2gray turn the real color image into the grey scale imageRgb2ind turn the real color image into the index color image3. The orders of the orthogonal transform and the inverse transformfft2 two-dimension fft transform ifft2 two-dimension fftinverse transformfftn N-dimensionfft transformifftn N-dimension fft inverse transform fftshift move the center of the spectrum by fft,fft2 and fftn transformsinto the center of the matrix or the vectordct2 two-dimension dct transform idct2 two-dimension dctinverse transform三.Experimental contents:1. read/write and show the image:① Read cameraman.tif file;② Examine the related information of the image and point out the file layout and the type ofthe image;③ Show the image and observe its zoom;④ Show the color bar;⑤ Show the image in imagesc function. Its grey-scale range is 64-128;⑥ Map cameraman.tif into the surface of the cylinder in the warp order;⑦ Load the mri images in the load order and show these images in the montage function,then, turn these image into the cartoon and show the cartoon in the movie function. Attention: the immovie function is applied only to the index image.Cue: load mrimontage (data matrix of the mri, the color map matrix of the mri)mov =immovie (data matrix of the mri, the color map matrix of the mri)colormap (map )movie (mov )2. Transformations between the images of the different type① Turn the RGB image flowers.tif into the grey scale image. Show and compare the twoimages in the same image window;② Turn the index image chess.mat into the grey scale image. Show and compare the twoimages in the same image window;③ Turn the grey scale image cameraman.tif into the binary image (realize individually inthe im2bw and the dither), show and compare the three images in the same image window;④ Turn the grey scale image pout.tif into the index image X (the corresponding colorimages are the gray (128) and gray (16) ). Show and compare the three images in the same image window;3. The orthogonal transform and inverse transform①Calculate two-dimension fast Fourier transform of the saturn2 image and show its spectrum amplitude .Cue: extract the image: load imdemos saturn2②Do the DCT transform to the saturn2 image.③Do two-dimension hadamard transform to the saturn2 image.Cue: firstly: create a two-dimension hadamard orthogonal matrix in the matlab, then,image data multiply the orthogonal matrix.④What are differences of the ①②③ transformations in the energy focus?⑤Remake ①—④ to the autumn.tif image.Cue: need to turn the image into the grey scale image.四.Thought after the class1. Which are the file layouts of image? How do these transformations each other? Which are image types? How do these transformations each other? How do the images of the different type show? Which are the data matrixes of image? How do these transformations each other?2. Which types of image can not be used directly to image processing?EXPERIMENT 2 Image Enhancement 一.Experimental purpose1. Master the fundamental method of the image enhancement and observe the results of theimage enhancement;2. Be familiar with the denoise method of the image processing;3. Be familiar with the transformations of the file layouts and of the color systems;二.Be familiar with the common orders as follows:imadust adjust the contrast by the histogram transformationhisteq histogram equalizationhist show the histogram of the image dataimnoise add the representative noise to the image(gaussian,salt&pepper, speckle)medfilt2 two-dimension median filteringordfilt2 two-dimension sequential statistic filteringwiener2 two-dimension Wiener filtering三.Experimental contents:1.Contrast enhancement① Read the cameraman.tif file;② Show the original image;③ Show the histogram of the image;④ Enhance the contrast of image by the histeq⑤ Show the histogram of the image after the contrast and compare it with the histogram ofthe list ③;⑥ Show the image after the contrast and compare it with the original image.四. Image smoothing① Read the eight,tif file. Show the images added individually by the Gaussiannoise, Salt & pepper noise and multiplicative noise and compare these images.② Three previous images added by the noise make individually two-dimensionmedian filtering, two-dimension sequential statistic filtering and two-dimension Wiener filtering③Compare the original image with the image polluted by the noise and the image after thefilter. Think that which filter is effective to suppress the corresponding noise and the influence of the neighborhood to suppressing noise and image blurring.五. The color of the RGB image flowers.tif becomes more clear and bright.①Read the flower.tif file;②Show the image;③Color space transformation. Turn the RGB color space into the HSV color space(transform function is rgb2hsv )④Enhance saturation component S by the histogram equalization in the HSV color space;⑤Return the HSV color space into the RGB color space;⑥Compare the images transformed previously with the original image and observe whetherthese become more clear and bright.六. Thought after the classWhy the image is dealt with by the Histogram Equalization? Which methods of the image enhancement you can think?EXPERIMENT 3 Boundary Detection and Texture Detection一. Experimental purpose1. Be familiar with the common orders of the boundary detection and boundary detection operator;2. Be familiar with the methods of the boundary detection.二. Be familiar with the common orders as follows:Edgethe boundary detection Sobel Sobel operatorCanny a antinoise and keeping weak boundary operator Robert Robert operatorPrewitt Prewitt operatorLog Log operator(Marr)blkproc block treatingstd22D standard deviation imhist image grey scale statistic三. Experimental contents:1. Boundary detection① Read the rice.tif file;② Show the image;③ Show five images detected individually in the Sober operator, Robert operator, Prewitt operator, Log operator, Canny operator and observe the difference of connectivity in the difference operators. Find the effective method of boundary detection to the rice.tif file. Cue: BW=edge (data matrix of the image, ‘operator’)④ Reduplicate the operation of ①②③ operations to the Saturn.tif image.⑤Help menu->demos->toolboxes->image processing->morphology, analysis and segmentation->egde detection in the matlab. Operate the demo program. Observe the value of the boundary detection by choosing the different images and operators.2. Texture detectionTexture detection can be realized by the method of local grey-scale statistic. The common methods have 2D standard deviation measurement and information entropy measurement. Texture detection is the method of the local detection. So, the texture detection can be realized by the blocking method. Computing formulas of standard deviation and information entropy are()p E is the grey scale mean. k p is the probability of the k grade grey scale.Compute the information entropy of the image by programming function and analyze the texture of the 4×4 block,8×8 block to image in the texture analyse of information entropy.()[]∑∞=−=12k k k p p E x D ∑−=kkk p p E logCue: Refer to the following example during the programming. Attention: firstly, Program information entropy function yourself. (MATLAB supplies 2D standard deviation function in the command line fun=@std2 )Example: texture analyse of the 8×8 sub-block to image in 2D standard deviation measurement.man=imread('cameraman.tif');fun=@std2; % std2 is the 2D standard deviation function.text1=blkproc(man,[8 8],fun);text=imresize(text1,[256 256],'bicubic');subplot(121);imshow(man);title('cameraman');subplot(122);imshow(text,[]); title('8X8 std');EXPERIMENT 4 Image Compression Encoding一. Experimental purpose1. Be familiar with the fundamental of the image compression encoding;2. Be familiar with the fundamental performance of the orthogonal image compression encoding.二.Be familiar with the common orders as follows:dct2 - Compute 2-D discrete cosine transformdctmtx - Compute discrete cosine transform matrix.fft2 - Compute 2-D fast Fourier transform .fftshift - Reverse quadrants of output of FFT.idct2 - Compute 2-D inverse discrete cosine transform.ifft2 - Compute 2-D inverse fast Fourier transform.Hadamard - Hadamard matrix.bestblk - Choose block size for block processing.blkproc - Implement distinct block processing for image.col2im - Rearrange matrix columns into blocks.im2col - Rearrange image blocks into columns.三.Experimental contents:1. Compress the image in the FFT transformation;①Read the rice.tif file;②Normalize the image;③Show the original image;④The image compression ratio is 4:1;⑤Separate the image to the 16×16 sub-image and make the FFT transform;⑥Realign the transform coefficient matrix and Sequence the coefficient matrix;⑦Reserve the higher-order coefficient according to the compression ratio;⑧Realign the coefficient matrix⑨Obtain the recovery images of the sub-images by the FFT inverse transform to sub-images;⑩Show the image compressed and compare it with the original image.2. Compress individually the image in the DCT and HT transforms according to the upper steps. Cue: the orders of the blocking and Hadamard transforms in the Hadamard transform. areT= hadamarda(image blocking size);for example, the image is separated 16×16 blocking, so the blocking size is 16.Hdcoe=blkproc(the image normalized,[16 16]),’P1*x*P2’,T,T)。