Download presentation
Presentation is loading. Please wait.
Published byHester Harmon Modified over 8 years ago
1
1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng Chapter 2: Images and M ATLAB
2
2 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.1 Grayscale Images M ATLAB is a data analysis software package with powerful support for matrices and matrix operations Command window Reads pixel values from an image Ch2-p.21
3
3 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.1 Grayscale Images Creates a figure on the screen A figure is a window in which a graphics object can be placed figure Ch2-p.22
4
4 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.1 Grayscale Images displays the matrix w as an image turns on the pixel values in our figure They appear at the bottom of the figure in the form imshow(w)pixval on Ch2-p.22
5
5 FIGURE 2.1 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch2-p.23
6
6 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.2 RGB Images Note that the command pixval on may be removed in a later M ATLAB version Ch2-p.23
7
7 © 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 2.2 Ch2-p.24
8
8 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.2 RGB Images Multidimensional array 206 (rows) 345 (columns) 3 (pages) 25 Ch2-p.24
9
9 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.2 RGB Images or or function impixel 75 25 30 Ch2-p.25
10
10 2.3 Indexed Color Images © 2010 Cengage Learning Engineering. All Rights Reserved. >> figure, imshow(‘trees.tif’) Ch2-p.25 >> em = imread(‘trees.tif’); >> figure, imshow(em)
11
11 2.3 Indexed Color Images © 2010 Cengage Learning Engineering. All Rights Reserved. Information about Your Image A great deal of information can be obtained with the imfinfo function >> [em, emap] = imread(‘trees.tif’); >> figure, imshow(em, emap) Ch2-p.26
12
12 2.4 Data Types and Conversions © 2010 Cengage Learning Engineering. All Rights Reserved. Ch2-p.28
13
13 2.4 Data Types and Conversions © 2010 Cengage Learning Engineering. All Rights Reserved. Ch2-p.28
14
14 2.5 Images Files and Formats © 2010 Cengage Learning Engineering. All Rights Reserved. You can use M ATLAB for image processing very happily without ever really knowing the difference between GIF, TIFF, PNG, etc. However, some knowledge of the different graphics formats can be extremely useful in order to make a reasoned decision Ch2-p.29
15
15 © 2010 Cengage Learning Engineering. All Rights Reserved. Header information This will, at the very least, include the size of the image in pixels (height and width) It may also include the color map, compression used, and a description of the image 2.5 Images Files and Formats Ch2-p.29
16
16 © 2010 Cengage Learning Engineering. All Rights Reserved. The imread and imwrite functions of M ATLAB currently support the following formats JPEG These images are created using the Joint Photographics Experts Group compression method (ch14) TIFF A very general format that supports different compression methods, multiple images per file, and binary, grayscale, truecolor, and indexed images 2.5 Images Files and Formats Ch2-p.30
17
17 GIF A venerable format designed for data transfer. It is still popular and well supported, but is somewhat restricted in the image types it can handle BMP Microsoft Bitmap format has become very popular and is used by Microsoft operating systems PNG, HDF, PCX, XWD, ICO, CUR 2.5 Images Files and Formats © 2010 Cengage Learning Engineering. All Rights Reserved. Ch2-p.30
18
18 A HEXADECIMAL DUMP FUNCTION FIGURE 2.3 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch2-p.30
19
19 2.5.1 Vector versus Raster Images © 2010 Cengage Learning Engineering. All Rights Reserved. We may store image information in two different ways Vector images: a collection of lines or vectors Raster images: a collection of dots The great bulk of image file formats store images as raster information Ch2-p.31-32
20
20 2.5.2 A Simple Raster Format © 2010 Cengage Learning Engineering. All Rights Reserved. As well as containing all pixel information, an image file must contain some header information this must include the size of the image, but may also include some documentation, a color map, and the compression used e.g. PGM format was designed to be a generic format used for conversion between other formats Ch2-p.32
21
21 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.5.3 Microsoft BMP Ch2-p.33
22
22 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.5.3 Microsoft BMP Ch2-p.33
23
23 The image width is given by bytes 18–21; they are in the second row 42 00 00 00 To find the actual width, we reorder these bytes back-to- front: 00 00 00 42 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.5.3 Microsoft BMP Ch2-p.34
24
24 Now we can convert to decimal (4×16 1 )+(2×16 0 ) = 66 which is the image width in pixels The image height 1F 00 00 00 (1×16 1 )+(F×16 0 ) = 31 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.5.3 Microsoft BMP Ch2-p.34
25
25 GIF Colors are stored using a color map. The GIF specification allows a maximum of 256 colors per image GIF doesn’t allow binary or grayscale images, except as can be produced with RGB values The pixel data is compressed using LZW (Lempel-Ziv-Welch) compression The GIF format allows multiple images per file. This aspect can be used to create animated GIFs © 2010 Cengage Learning Engineering. All Rights Reserved. 2.5.4 GIF and PNG Ch2-p.34-35
26
26 PNG The PNG format has been more recently designed to replace GIF and to overcome some of GIF’s disadvantages Does not rely on any patented algorithms, and it supports more image types than GIF Supports grayscale, true color, and indexed images Moreover, its compression utility, zlib, always results in genuine compression © 2010 Cengage Learning Engineering. All Rights Reserved. 2.5.4 GIF and PNG Ch2-p.35
27
27 The JPEG algorithm uses lossy compression, in which not all the original data can be recovered © 2010 Cengage Learning Engineering. All Rights Reserved. 2.5.5 JPEG Ch2-p.35-36
28
28 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.5.5 JPEG Ch2-p.36
29
29 2.5.6 TIFF © 2010 Cengage Learning Engineering. All Rights Reserved. One of the most comprehensive image formats Can store multiple images per file Allows different compression routines and different byte orderings Allows binary, grayscale, truecolor or indexed images, and opacity or transparency An excellent format for data exchange Ch2-p.36-37
30
30 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.5.6 TIFF Ch2-p.37
31
31 © 2010 Cengage Learning Engineering. All Rights Reserved. 2.5.6 TIFF This particular image uses the little-endian byte ordering The first image in this file (which is in fact the only image), begins at byte Because this is a little-endian file, we reverse the order of the bytes: 00 01 01 E0. This works out to 66016 Ch2-p.37
32
32 2.5.7 DICOM © 2010 Cengage Learning Engineering. All Rights Reserved. DICOM (Digital Imaging and Communications in Medicine) Like GIF, may hold multiple image files May be considered as slices or frames of a three dimensional object The DICOM specification is huge and complex. Drafts have been published on the World Wide Web Ch2-p.37-38
33
33 2.5.8 Files in M ATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. Which writes the image stored in matrix X with color map map (if appropriate) to file filename with format fmt Without the map argument, the image data is supposed to be grayscale or RGB e.g. Ch2-p.38
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.