02 Images and Matlab

Embed Size (px)

Citation preview

  • 8/8/2019 02 Images and Matlab

    1/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-1

    Images and Matlab

    Prof. Eric Miller

    [email protected]

  • 8/8/2019 02 Images and Matlab

    2/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-2

    Representation of Images

    All images in this class are going to bediscrete

    Represented as information defined onan array (pixels)

    Array indexed by rows, columns, or

    lexicographically Different types of images have differentstuff at each pixel

  • 8/8/2019 02 Images and Matlab

    3/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-3

    Images

    Rows

    Columns

    1

    2

    3

    MM-1

    1 2 3 N

    1

    2

    3

    M-1

    M

    M+1

    M+2

    MN

    2M+1

    Mostly work with row and

    column indexing

    Occasionally, want to use

    single index

    X(2,2) = information

    in pixel on row 2

    and column 2 inimage X

    X(M+2) = info. in pixelon row 2 and column

    2 in image X

  • 8/8/2019 02 Images and Matlab

    4/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-4

    Types of Images x(m,n) = 0 or 1: binary image

    x(m,n) = 0, 1, 2, P-1: grayscale image P typically something like 256, 512 or some power of 2.

    256 is really the most common

    0 = black, P = white x(m,n) = [0 to P-1, 0 to P-1, 0 to P-1]

    Red, green, blue color image

    Like three grayscale images x(m,n) = index into color map.

    Color map = three column table with all possible colors Image index says which row in that table gives RBG values

    for that pixel

    So long as table is known, very easy to store indices

  • 8/8/2019 02 Images and Matlab

    5/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-5

    Examples

    Binary

    Grayscale (256 levels)

    RGB

    Indexed

    How to tell

    difference?

  • 8/8/2019 02 Images and Matlab

    6/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-6

    Matlab

    Wonderful tool for doing all sorts ofcomputational things

    Well use it here for image processing

    Resources Formal tutorial on the class web site.

    See especially sections 1, 2, 3, 4, 9, 12

    Appendix to the text

    Code used in class posted to the web site

    Can always type help command

  • 8/8/2019 02 Images and Matlab

    7/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-7

    Matlab Concepts Covered Reading images with imread

    Plotting images with imshow

    Getting pixel values with impixelinfo NOT pixval as in the text Making a figure window

    with figure

    Getting image file information with imfinfo

    Multiple plots using subplot

    Printing information to screen using disp

    Indexing arrays using colon :

    Use of semicolon to suppress output

  • 8/8/2019 02 Images and Matlab

    8/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-8

    Image File Formats

    Standards for storing images on

    computers

    Some better than others for different

    things (e.g. compression)

    imread will deal with all of the ones we

    care about

  • 8/8/2019 02 Images and Matlab

    9/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-9

    Common Formats

    BMP

    Microsoft format

    Header followed by pixel information

    Lossless compression GIF, PNG

    Compuserve

    Color only

    Lossless compression More than one image per file

  • 8/8/2019 02 Images and Matlab

    10/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-10

    Formats

    JPEG (Joint Photographicc Experts

    Group)

    Lossy compression so much smaller files

    TIFF (Tagged Image File Format)

    All sorts of compression

    All sorts of storage schemes

    All sorts of color schemes

  • 8/8/2019 02 Images and Matlab

    11/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-11

    JPEG HeaderField Size (bytes) DescriptionAPP0 Marker 2 Always equals 0xFFE0

    Length 2 Length of segment excluding APP0 marker

    Identifier 5 Always equals "JFIF\x00" (0x4A46494600)

    Version 2 First byte is major version (currently 0x01),

    Second byte is minor version (currently 0x02)

    Density Units 1 Units for pixel density fields

    * 0 - No units, aspect ratio only specified

    * 1 - Pixels per Inch

    * 2 - Pixels per CentimetreX Density 2 Integer horizontal pixel density

    Y Density 2 Integer vertical pixel density

    Thumbnail Width 1 Horizontal size of embedded JFIF thumbnail in pixels

    Thumbnail Height 1 Vertical size of embedded JFIF thumbnail in pixels

    Thumbnail Data 3*W*H Uncompressed 24 bit RGB raster thumbnail

  • 8/8/2019 02 Images and Matlab

    12/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-12

    BMP Header

  • 8/8/2019 02 Images and Matlab

    13/13

    Fall 2007 EN 74-ECE Image Processing Lecture 2-13

    Matlab Data Types Different means of representing numbers

    depending on what you want to do

    Examples: Floating point numbers for scientific applications

    2.3543, -7.8956

    Integers: 1, 2, -7, 6354, -2333430948

    Unsigned integers for positive things (like pixelvalues): 255, 7, 0

    Question: Can computers represent numberslike ore?