当前位置:
文档之家› 专题之二:图像获取及图像预处理-2015
专题之二:图像获取及图像预处理-2015
Step 2: Retrieve Hardware Information In this step, we get several pieces of information that the toolbox needs to uniquely identify the image acquisition device you want to access. The imaqhwinfo function is used to retrieve each item. e.g: dev_info = imaqhwinfo('winvideohot(vid);%get a frame image imshow(frame); stop(vid) Step 7: Clean Up When you finish using your image acquisition objects, you can remove them from memory and clear the MATLAB workspace of the variables associated with these objects. delete(vid) Clear close(gcf)
专题之二:图像获取及图像预处理
•图像获取:利用相机或其它成像设备产生 2D或3D场景的数字图像以及对图像的表示。 •图像预处理:改善图像质量的处理称为图 像预处理,主要是指按需要对图像进行适 当的变换突出其有用的信息,去除或消弱 无用的信息,如改变图像对比度、去除噪 声或强调边缘的处理以及将观测到的不同 图像在同一约束条件下进行校正处理等。
Step 3: Create a Video Input Object In this step we create the video input object that the toolbox uses to represent the connection between MATLAB and an image acquisition device. Using the properties of a video input object, we can control many aspects of the image acquisition process. To create a video input object, we use the videoinput function. e.g: vid = videoinput('winvideo',1,'YUY2_320x240')
Running an Example: % Create video input object. vid = videoinput('winvideo',1,'YUY2_320x240') % Set video input object properties for this application. set(vid,'TriggerRepeat',Inf); vid.FrameGrabInterval = 5; % Set value of a video source object property. vid_src = getselectedsource(vid); preview(vid) figure; % Create a figure window. start(vid) % Start acquiring frames.
Step 5: Configure Object Properties (Optional) After creating the video input object and previewing the video stream, you might want to modify characteristics of the image or other aspects of the acquisition process. You accomplish this by setting the values of image acquisition object properties. This section Describes the types of image acquisition objects used by the toolbox Describes how to view all the properties supported by these objects, with their current values. E.g: get(vid) or get(getselectedsource(vid)) Describes how to set the values of object properties e.g: To implement continuous image acquisition, set(vid,'TriggerRepeat',Inf) To help the application keep up with the incoming video stream while processing data: vid.FrameGrabInterval = 5;
视觉系统开发的软件环境
视觉系统的主要工作是图像采集之后的后期处理,包 括从图像预处理、图像分割、形态学处理、特征提取、目 标识别和3D定位的一系列内容。 本课程涉及的各种算法是基于MATLAB实现的。之所 以选择MATLAB是因为MATLAB可以加速创新与算法开发。 MATLAB是由Math Works公司开发的著名数学软件。世界 上很多科研人员使用MATLAB来缩短数据分析和算法开发 的时间,研发出更加先进的产品和技术。MATLAB 作为科 学计算的基础平台,提供了强大的科学计算能力和丰富的 数据可视化功能,并且还提供了一种易学易用的科学算法 开发语言。目前, MATLAB 产品已经被广泛认可为科学计 算领域内的标准软件工具之一。选择MATLAB的另外一个 原因就是MATLAB的开放性、可扩展性强,能够与 C, C++ 以及 Excel 集成使用。
Basic Image Acquisition Procedure:
This section illustrates the basic steps required to create an image acquisition application by implementing a simple motion detection application. The application detects movement in a scene by performing a pixel-to-pixel comparison in pairs of incoming image frames. If nothing moves in the scene, pixel values remain the same in each frame. When something moves in the image, the application displays the pixels that have changed values.
Basic Image Acquisition Procedure
Step 1: Install Your Image Acquisition Device Step 2: Retrieve Hardware Information Step 3: Create a Video Input Object Step 4: Preview the Video Stream (Optional) Step 5: Configure Object Properties (Optional) Step 6: Acquire Image Data Step 7: Clean Up
Step 4: Preview the Video Stream (Optional) After you create the video input object, MATLAB is able to access the image acquisition device and is ready to acquire data. However, before you begin, you might want to see a preview of the video stream to make sure that the image is satisfactory. For example, you might want to change the position of the camera, change the lighting, correct the focus, or make some other change to your image acquisition setup. The preview function is used to preview the video stream. e.g: preview(vid) closepreview(vid)
Step 6: Acquire Image Data After you create the video input object and configure its properties, you can acquire data. This is typically the core of any image acquisition application, and it involves these steps: Starting the video input object — You start an object by calling the start function. Triggering the acquisition — To acquire data, a video input object must execute a trigger. Bringing data into the MATLAB workspace — The toolbox stores acquired data in a memory buffer, a disk file, or both, depending on the value of the video input object LoggingMode property. To bring multiple frames into the workspace, use the getdata function.