
图像处理实验任务书2013版.doc
24页《图像处理》实验指导书10学时实验报告要求1、 做好实验相关预习工作,了解实验的目的与内容每次实验报告中,首先写清实验目的然后,写出实验内容中的题目、程序清单(加上必要注释)、程序运行结果 (可将图像处理效果图附在实验报告中;对综合应用性较高的题目,要求在给出代码前,绘制算法设计的流程图)最后,给出100-50字的实验体会或总结要求必须写在实验报告中,图片效果可以剪贴到报告册上每次实验报告首页页眉写上实验时间、指导老师姓名2、 实验报告要求手写在实验报告册中,请勿打印实验一 Matlab图像显示与图像运算 (2学时)【实验目的】1、 熟悉Matlab的编程环境及其基本用法;2、 掌握MATLAB语言中图像数据与信息的读取方法;了解m文件的编写与调试方法;3、 熟悉图像点运算和代数运算的实现方法;4、 掌握Matlab图像几何变换的基本函数;5、 了解图像几何运算的简单应用;【实验内容】1、Introduction In the following we give a short overview on a very limited set of basic image processing functions provided by MATLAB. The function descriptions only cover the basic usage, more detailed information can be found in the manual pages by typing doc functionName at the MATLAB command line. MATLAB provides with it’s image processing toolbox many powerful and very efficient image processing functions (see function list of the image processing toolbox). With this it is very simple to implement complex image processing applications, especially for fast prototyping. On the backside, a lot of understanding how image processing works is hidden within black boxes and temps to make things more complicate than they really are.2、Image representationIn MATLAB a binary and gray-scale image is represented by one 2-dimensional array, whereas a color image are represented by a 3-dimensional array (one 2-dimensional array for each of the color planes or color channels red, green and blue):The origin of the image is in the upper left and the size of the image is defined by the parameter width (number of columns of the array) and height (number of rows of the array). Note that the x- and y-coordinates are chosen such that the z-axis points to the front.A single point within the image is called pixel. A gray-scale or binary pixel consists of one data value, a color pixel consists of 3 data values (each for one of the color channels). The most common data types of the individual pixels are:uint8 unsigned integer: data range 0..255double double precision float: data range 0.0 ... 1.0Binary images have pixel values of 0’s and 1’s resp. 0.0 and 1.0. In the case of uint8 images, the logical flag must be turned on, to be recognized as binary image (for details see below). Be careful with data types in MATLAB. Many of the predefined functions, e.g. imadd(img1, img2) which adds two images, just truncates data values to 255 on uint8-arrays ... make sure if that is what you want.Hints: To avoid problems with data types, especially when working with predefined image processing functions, it is advisory to work with type double and make sure that data is scaled to the range 0 ... 1.0.3、Basic MATLAB functions3.1 MATLAB manualdoc functionname displays the manual for the MATLAB function functionnamedoc images the manual for the image processing toolboxdoc imaq the manual for the image acquisition toolbox3.2 Image informationimfinfo(’foo.ext’) displays information on image format etc. of the file foo.extimformats displays an overview of all MATLAB image formatswhos img displays information about the array img: size, data type, etc.3.3 Reading, writing and displaying imagesmyImg = imread(’foo.ext’) reads file foo.ext into array myImg, image format is determined by the file extension (jpg, tiff, tif, gif, bmp, png, ...)imwrite(anImg, ’foo.ext’) writes the image anImg to the file foo.ext, where the image format is chosen according to the extension ext. Valid extensions are: tif, tiff, jpg, jpeg, gif, pngimshow(myImg) displays the image myImg as gray-scale, binary or color imagedepending on the data type of myImgimshow(myImg,[]) the image myImg as gray-scale, binary or color image depending on the data type of myImg and scales the image properlyfigure(n) opens a new window with number n, the next call to imshow() displays the image within this window3.4 Basic image processing functionsislogical(binImg) checks whether array binImg has the logical flag set or not (returns value 1 or 0)img = uint8(zeros(512,1024)) creates a black image with width 1024 and height 512 of type uint8img = uint8(255*ones(512,1024)) creates a white image with width 1024 and height 512 of type uint8img = double(zeros(512,1024)) creates a black image with width 1024 and height 512 of type doubleimg = double(ones(512,1024)) creates a white image with width 1024 and height 512 of type double[height width d] = size(myImg) retrieves height and width and stores the values in variables height and width, d ist set to the array dimension.red = myImg(:,:,1) stores the red component of myImg (rgb-image) in array redgreen = myImg(:,:,2) stores the red component of myImg in array greenblue = myImg(:,:,3) stores the red component of myImg in array bluemx。












