Презентация на тему: " 7/29/2015Image Processing 1 Image Processing Using Matlab*" — Транскрипт:
7/29/2015Image Processing 1 Image Processing Using Matlab*
7/29/2015 Image Processing2 What is the Image Processing Toolbox? The Image Processing Toolbox is a collection of functions that extend the capability of the MATLAB ® numeric computing environment. Many of the toolbox functions are MATLAB M-files, series of MATLAB statements that implement specialized image processing algorithms.
7/29/2015 Image Processing3 Image Processing Toolbox Cont. Geometric operations Neighborhood and block operations Linear filtering and filter design Transforms Image analysis and enhancement Binary image operations Region of interest operations
7/29/2015 Image Processing4 IP Toolbox You can view the MATLAB code for these functions using the statement: type function_name You can extend the capabilities of the Image Processing Toolbox by writing your own M-files, or by using the toolbox in combination with other toolboxes, such as the Signal Processing Toolbox and the Wavelet Toolbox.
7/29/2015 Image Processing5 Images in the Image Processing Toolbox The basic data structure in MATLAB is the array, an ordered set of real or complex elements. MATLAB stores most images as two- dimensional arrays (i.e., matrices), in which each element of the matrix corresponds to a single pixel in the displayed image. For example, you can select a single pixel from an image matrix using normal matrix subscripting: I(2,15)
7/29/2015 Image Processing6 IP Toolbox – Data Types By default, MATLAB stores most data in arrays of class double. The data in these arrays is stored as double precision (64-bit) floating-point numbers. All of MATLABs functions and capabilities work with these arrays. (Not always ideal for images: 1000x1000 pixels = 8 Millions bytes!!!)
7/29/2015 Image Processing7 Data Types Continued In order to reduce memory requirements, MATLAB supports storing image data in arrays of class uint8. The data in these arrays is stored as 8-bit unsigned integers. Data stored in uint8 arrays requires one eighth as much memory as data in double arrays. (Noninteger values cannot be stored in uint8 arrays, for example, but they can be stored in double arrays.)
7/29/2015 Image Processing8 Image Types in the Toolbox The Image Processing Toolbox supports four basic types of images: Indexed images Intensity images (grey image) Binary images RGB images
7/29/2015 Image Processing9 Indexed Images An indexed image consists of two arrays, an image matrix and a colormap. The colormap is an ordered set of values that represent the colors in the image. For each image pixel, the image matrix contains a value that is an index into the colormap.
7/29/2015 Image Processing10 Indexed Images Cont. The colormap is an m-by-3 matrix of class double. Each row of the colormap matrix specifies the red, green, and blue (RGB) values for a single color: color = [R G B] R, G, and B are real scalars that range from 0 (black) to 1.0 (full intensity).
7/29/2015 Image Processing11 Indexed Image Example
7/29/2015 Image Processing12 Indexed Images Cont. The pixels in the image are represented by integers, which are pointers (indices) to color values stored in the colormap. If the image matrix is of class double, the value 1 points to the first row in the colormap, the value 2 points to the second row, and so on. (The previous image is a set of doubles). If the image matrix is of class uint8, there is an offset; the value 0 points to the first row in the colormap, the value 1 points to the second row, and so on.
7/29/2015 Image Processing13 Image Types – Intensity Images MATLAB stores an intensity image as a single matrix, with each element of the matrix corresponding to one image pixel. The matrix can be of class double, in which case it contains values in the range [0,1], or of class uint8, in which case the data range is [0,255] (0 – black, 255 – white).
7/29/2015 Image Processing15 Image Types – Binary Images In a binary image, each pixel assumes one of only two discrete values. Essentially, these two values correspond to on and off. A binary image is stored as a two- dimensional matrix of 0s (off pixels) and 1s (on pixels).
7/29/2015 Image Processing16 Binary Image - Example
7/29/2015 Image Processing17 Image Types – RGB Images Like an indexed image, an RGB image represents each pixel color as a set of three values, representing the red, green, and blue intensities that make up the color. Unlike an indexed image, however, these intensity values are stored directly in the image array, not indirectly in a colormap.
7/29/2015 Image Processing18 RGB Images In MATLAB, the red, green, and blue components of an RGB image reside in a single m-by-n-by-3 array. m and n are the numbers of rows and columns of pixels in the image, and the third dimension consists of three planes, containing red, green, and blue intensity values. For each pixel in the image, the red, green, and blue elements combine to create the pixels actual color.
7/29/2015 Image Processing19 RGB Images For example, to determine the color of the pixel (112,86), look at the RGB triplet stored in(112,86,1:3). Suppose (112,86,1) contains the value , (112,86,2) contains , and (112,86,3) contains The color for the pixel at (112,86) is:
7/29/2015 Image Processing20 RGB Images An RGB array can be of class double, in which case it contains values in the range [0,1]. class uint8, in which case the data range is [0,255].
7/29/2015 Image Processing22 Working with Image Data Reading in image data from files, and writing image data out to files Converting images to other image types Working with uint8 arrays in MATLAB and the Image Processing Toolbox
7/29/2015 Image Processing23 Reading Images You can use the MATLAB imread function to read image data from files. imread can read these graphics file formats: BMP HDF JPEG PCX TIFF XWD
7/29/2015 Image Processing24 Writing Images To write image data from MATLAB to a file, use the imwrite function. imwrite can write the same file formats that imread reads. In addition, you can use the imfinfo function to return information about the image data in a file. See the reference entries for imread, imwrite, and imfinfo for more information about these functions
7/29/2015 Image Processing25 Converting Images FunctionPurpose ditherbinary from grayscale rgb2indindexed from RGB gray2ind indexed from grayscale graysliceindexed from grayscale by thresholding im2bwbinary from intensity, indexed or RGB image by luminance threshold.
7/29/2015 Image Processing26 Converting Images ind2grayindexed to grayscale ind2rgbindexed to RGB mat2graycreate a grayscale intensity image from data in a matrix, by scaling the data rgb2grayRGB to intensity rgb2indRGB to indexed
7/29/2015 Image Processing27 Coordinate Systems Locations in an image can be expressed in various coordinate systems, depending on context. This section discusses the two main coordinate systems used in the Image Processing Toolbox, and the relationship between them. These systems are: The pixel coordinate system The spatial coordinate system
7/29/2015 Image Processing28 Pixel Coordinates Generally, the most convenient method for expressing locations in an image is to use pixel coordinates. In this coordinate system, the image is treated as a grid of discrete elements, ordered from top to bottom and left to right.
7/29/2015 Image Processing29 Pixel Coordinates For pixel coordinates, the first component r (the row) increases downward, while the second component c (the column) increases to the right. Pixel coordinates are integer values and range between 1 and the length of the row or column.
7/29/2015 Image Processing31 Pixel Coordinates in Matlab There is a one-to-one correspondence between pixel coordinates and the coordinates MATLAB uses for matrix subscripting. This correspondence makes the relationship between an images data matrix and the way the image displays easy to understand. For example, the data for the pixel in the fifth row, second column is stored in the matrix element (5,2).
7/29/2015 Image Processing32 Spatial Coordinates In the pixel coordinate system, a pixel is treated as a discrete unit, uniquely identified by a single coordinate pair, such as (5,2). From this perspective, a location such as (5.3,2.2) is not meaningful. At times, however, it is useful to think of a pixel as a square patch, having area.
7/29/2015 Image Processing33 Spatial Coordinates Notice that y increases downward:
7/29/2015 Image Processing34 Pixel vs. Spatial In pixel coordinates, the upper-left corner of an image is (1,1), while in spatial coordinates, this location by default is (0.5,0.5). This difference is due to the pixel coordinate system being discrete, while the spatial coordinate system is continuous.
7/29/2015 Image Processing35 Assignment 1 In Matlab* create these images. They will take as parameters the number of circles**.
7/29/2015 Image Processing36 Assignment 1 cont. * Either in Matlab or any other method you may choose. ** or square as the case may be. Due September 20 th (Campus) September 12 th (Raytheon) Submit code on the Learning Portal