Part1 [Compatibility Mode]

Embed Size (px)

Citation preview

  • 8/2/2019 Part1 [Compatibility Mode]

    1/43

    1

    Unacional Bogota

    Image and Video ProcessingFundamentals

    Professor Ebroul Izquierdo

    Multimedia and Vision Research Group

    Queen Mary, University of London

    Summer Course, Universidad Nacional de Colombia

    Bogota, Marzo-June 2012

    Electronic Engineering

    Road Map

    Digital image representation

    Sampling

    Quantization

    Colour spaces

    Colour images

  • 8/2/2019 Part1 [Compatibility Mode]

    2/43

    2

    Electronic Engineering

    What is a Digital Image?

    A discrete function from a 2D domain in a set of realpositive numbers

    Digital image:

    Having values at discrete samples usually in a regular

    rectilinear gridThe function values represent gray levels, colorchannels, opacities, transparency or tissue density in anMR Images

    DI:

    Electronic Engineering

    Types of Signals: Dimensions

    Temporal signal: function of time

    f(t): voice, music, nerve impulses, radar

    Spatial signal: function of two (or three) spatial dimensions

    f(x,y): images (grayscale, color, multi-spectral)

    f(x,y,z): medical scans (CT, MRI, PET)

    Spatial-temporal signal: 2/3-D space, 1-D time

    f(x,y, t): video/movies

  • 8/2/2019 Part1 [Compatibility Mode]

    3/43

    3

    Electronic Engineering

    Using a Single Sensor

    Electronic Engineering

    Using Sensor Strips

  • 8/2/2019 Part1 [Compatibility Mode]

    4/43

    4

    Electronic Engineering

    Using Sensor Arrays

    Electronic Engineering

    What does this mean?

    2D

    Domain

    Sampling Positions

  • 8/2/2019 Part1 [Compatibility Mode]

    5/43

    5

    Electronic Engineering

    What does this mean?

    Function

    Values at

    discrete

    grid

    points

    0 200

    128 60

    128 60

    128 60

    Electronic Engineering

    Pixels or Pels

    2D

    Domain

    Sampling Positions

    A Single

    sampling

    position

    and its

    function

    value

  • 8/2/2019 Part1 [Compatibility Mode]

    6/43

    6

    Electronic Engineering

    Digital Images (I)

    A digital image is a nD array of pixel values.

    For example, in the 2D case the image data contains information

    of the graylevel at each position in the image.

    Magnifyed pixels at few

    sampling positions

    Electronic Engineering

    Digital Images (II)

    94 100 104 119 125 136 143 153 157 158

    103 104 106 98 103 119 141 155 159 160

    109 136 136 123 95 78 117 149 155 160

    110 130 144 149 129 78 97 151 161 158

    109 137 178 167 119 78 101 185 188 161

    100 143 167 134 87 85 134 216 209 172

    104 123 166 161 155 160 205 229 218 181

    125 131 172 179 180 208 238 237 228 200

    131 148 172 175 188 228 239 238 228 206

    161 169 162 163 193 228 230 237 220 199

    Corresponding arrayPixels

  • 8/2/2019 Part1 [Compatibility Mode]

    7/43

    7

    Electronic Engineering

    Grey Level Images

    Standard pixel values for rows, columns and gray levels

    The number of gray levels is usually a power of 2:

    whereB is the number of bits in the binary representation of the

    image.

    E.g.,B = 8 impliesL = 256 gray levels numbered from 0,,255.

    Parameter Symbol Typical ValuesRows N 256, 512, 525, 625, 1024, 1035Colum ns M 256, 512, 768, 1024, 1320

    No. Gray Levels L 2, 64, 256, 1024, 4096, 16384

    L

    B

    2

    Electronic Engineering

    Image Formats (I)

    GIF(GIF87a,GIF89a):

    Graphics Interchange Format (GIF) devised by the

    UNISYS Corp. and Compuserve, initially for transmitting

    graphical images over phone lines via modems.Uses the Lempel-Ziv Welch algorithm (compression).

    Supports only 8-bit (256) color images.

    Supports interlacing

    GIF89a supports simple animation

  • 8/2/2019 Part1 [Compatibility Mode]

    8/43

    8

    Electronic Engineering

    Image Formats (II)

    JPEG:

    A standard for photographic image compression created by

    the Joint Photographics Experts Group

    Takes advantage of limitations in the human vision system

    to achieve high rates of compression

    Lossy compression which allows user to set the desired

    level of quality/compression

    More on JPEG later

    Electronic Engineering

    TIFF:

    Tagged Image File Format (TIFF), stores many

    different types of images (e.g., monochrome, grayscale,

    8-bit & 24-bit RGB, etc.)

    Developed by the Aldus Corp. in the 1980's and latersupported by the Microsoft

    TIFF is a lossless format (when not utilizing the new

    JPEG tag which allows for JPEG compression)

    It does not provide any major advantages over JPEG

    and is not as user-controllable it appears to be declining

    in popularity

    Image Formats (III)

  • 8/2/2019 Part1 [Compatibility Mode]

    9/43

  • 8/2/2019 Part1 [Compatibility Mode]

    10/43

    10

    Electronic Engineering

    A PPM header consists of at least three parts normally separated

    by carriage returns and/or linefeeds but the PPM specification

    only requires white space

    The first "line" is a magic PPM identifier, it can beP3 orP6

    The next line consists of the width and height of the image as ascii

    numbers

    The last part of the header gives the maximum value of the colour

    components for the pixels, this allows the format to describe morethan single byte (0..255) colour values

    In addition to the above required lines, a comment can be placed

    anywhere with a "#" character, the comment extends to the end of

    the line.

    PPM Header

    Electronic Engineering

    The following are all valid PPM headers.

    Example 1P6 1024 788 255

    Example 2P6

    1024 788# My own comment on this image

    255

    Example 3P3

    1024 # the image width

    788 # the image height

    # Another comment

    1023

    PPM Header

  • 8/2/2019 Part1 [Compatibility Mode]

    11/43

    11

    Electronic Engineering

    The format of the image data itself depends on the

    magic PPM identifier. If it is "P3" then:

    the image is given as ascii text

    the numerical value of each pixel ranges from 0 to the

    maximum value given in the header

    the lines should not be longer than 70 characters.

    PPM Header

    Electronic Engineering

    P3

    # example from the man page

    4 4

    15

    0 0 0 0 0 0 0 0 0 15 0 15

    6 0 0 0 15 7 0 7 0 0 0 0

    0 0 0 0 0 0 0 15 7 3 0 0

    15 0 15 0 0 0 0 0 0 0 6 0

    P3 PPM Header Example

  • 8/2/2019 Part1 [Compatibility Mode]

    12/43

    12

    Electronic Engineering

    If the PPM magic identifier is "P6" then the image

    data is stored in byte format, one byte per colour

    component (r,g,b)

    Comments can only occur before the last field of the

    header and only one byte may appear after the last

    header field, normally a carriage return or line feed

    "P6" image files are obviously smaller than "P3" andmuch faster to read

    Note that "P6" PPM files can only be used for single

    byte colours

    PPM Header

    Electronic Engineering

    While not required by the format specification it is a

    standard convention to store the image in top to

    bottom, left to right order

    Each pixel is stored as a byte

    The value 0 represents black,

    The value 255 represents white

    The components are stored in the "usual" order, R/G/B

    (red - green blue)

    PPM Format

  • 8/2/2019 Part1 [Compatibility Mode]

    13/43

    13

    Electronic Engineering

    This format is identical to PPM but it stores greyscale

    information

    That is, one value per pixel instead of 3 (r,g,b)

    The only difference in the header section is the magic

    identifiers which areP2 andP5

    P2 corresponds to the ascii form of the data

    P5 corresponds to the binary form of the data

    PGM Format

    Electronic Engineering

    P2

    24 7

    9

    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

    0 3 3 3 3 0 0 7 7 7 7 0 0 1 1 1 1 0 0 5 1 5 5 0

    0 3 0 0 0 0 0 7 0 0 0 0 0 1 0 0 0 0 0 5 0 0 1 0

    0 3 3 3 0 0 0 7 7 7 0 0 0 1 1 1 0 0 0 1 1 1 1 0

    0 3 0 0 0 0 0 7 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0

    0 3 0 0 0 0 0 7 7 7 7 0 0 1 1 1 1 0 0 1 0 0 0 0

    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

    PGM Example

  • 8/2/2019 Part1 [Compatibility Mode]

    14/43

    14

    Electronic Engineering

    P2 - PGM grey scale image, stored in ASCII, onevalue per pixelP3 - PPM color image, stored in ASCII, 3 valuesrgb per pixelP5 - PGM grey scal image stored in binary(compressed) formatP6 - PPM color image stored in binary(compressed) format

    PPM and PGM Magic Numbers

    Electronic Engineering

    Road Map

    Digital image representation

    Sampling

    Quantization

    Colour spaces

    Colour images

  • 8/2/2019 Part1 [Compatibility Mode]

    15/43

    15

    Electronic Engineering

    How Digital Images Are Generated

    Two basic step (Digitization):

    Sampling

    Quantization

    Electronic Engineering

    Image Digitization

    Digitizer(e.g.,scanner)

    SceneI(i, j)

  • 8/2/2019 Part1 [Compatibility Mode]

    16/43

    16

    Electronic Engineering

    Sampling

    Sampler

    Continuous Domain

    (i, j) array of

    sampling positions

    The continuous image domain D is scanned the brightness values

    I(i, j) are measured or sampled at discrete locations to form an

    array of intensity values

    Converting the continuous 2D signal in a digital image

    by sampling per scanlines

    Definition

  • 8/2/2019 Part1 [Compatibility Mode]

    17/43

    17

    Example

    Example

    Electronic Engineering

    Image sampling

  • 8/2/2019 Part1 [Compatibility Mode]

    18/43

    18

    Electronic Engineering

    Image sampling

    5122561286432

    Image Resolution

    Full Resolution 1/4 Resolution

  • 8/2/2019 Part1 [Compatibility Mode]

    19/43

    19

    Image Resolution

    1/8 ResolutionFull Resolution

    Low Resolution

    64 X 641/8 Resolution

    The Image at 1/8 resolution appears blocky

    To accurately represent the original continuous scene, the

    sampling rate must be sufficiently high

  • 8/2/2019 Part1 [Compatibility Mode]

    20/43

    20

    Electronic Engineering

    Methods for Image Sampling

    Uniform - same sampling frequency everywhere

    Adaptive - higher sampling frequency in areas with

    greater detail (Compression strategy)

    Electronic Engineering

    Representing a line with discrete pixel values leads tosampling error and loss of information

    Standard midpoint line on a binary representation

    Sampling Effects

  • 8/2/2019 Part1 [Compatibility Mode]

    21/43

    21

    Same line with twice the linear resolution

    Sampling Effects

    Electronic Engineering

    Doubling resolution does not solve the problem

    It costs 4 times memory, bandwidth and scan

    conversion time!

    The problem can be alleviated using more

    grey-levels

    Sampling Effects

  • 8/2/2019 Part1 [Compatibility Mode]

    22/43

    22

    Electronic Engineering

    Happen whenever we try to sample a signal at less thantwice the maximum frequency

    Analog sine wave

    The sine wave sampled at too low a rate

    Aliasing

    Electronic Engineering

    The sine wave sampled at too low a rate

    Reconstructed wave based on these samples

    Aliasing

  • 8/2/2019 Part1 [Compatibility Mode]

    23/43

    23

    Electronic Engineering

    Sine wave sampled at the Nyquist limit. This time it

    works fine

    The sample points shifted. Now we get no signal!

    Nyquist Limit

    Electronic Engineering

    Road Map

    Digital image representation

    Sampling

    Quantization

    Colour spaces

    Colour images

  • 8/2/2019 Part1 [Compatibility Mode]

    24/43

    24

    Electronic Engineering

    Quantization

    Each element in the matrix is quantized, i.e, replaced by an

    integer

    Quantized values are called gray levels

    I(i, j)

    Quantizer

    Digital Image Visualization

    Usually each pixel in the image is shown by a singlepixel on the screen.

    E.g., forL = 256 gray levels, 0 maps into black,

    255 into white and values in between map

    linearly into various levels of gray.

    0

    0

    0

    0

    0

    0

    0

    0

    0

    0 0 0

    127

    127255

    255

    Image Screen

  • 8/2/2019 Part1 [Compatibility Mode]

    25/43

    25

    Electronic Engineering

    Intensity Resolution

    Refers to how accurately a pixels gray level represents the

    brightness of the corresponding point in the original scene

    During quantization, the brightness sampled at each point in

    the continuous-tone image is replaced by an integer value

    Scene brightness

    Graylevelofimage

    0

    7

    Imax

    B = 3 bits

    Electronic Engineering

    Intensity Resolution

    Intensity resolution depends on the number of bits

    available

    This figure shows a digital image quantized with 8 bits (256

    gray levels). The image appears continuous

  • 8/2/2019 Part1 [Compatibility Mode]

    26/43

    26

    Electronic Engineering

    Intensity Resolution

    The same image quantized with only 4 bits (16 gray

    levels). Now the image brightness appears

    discontinuous

    Electronic Engineering

    Intensity Resolution

    With fewer bits, we cannot accurately represent thegradual intensity variations in the original scenebecause a wider range of intensities in the original

    scene is mapped into a single gray level.

    Generally, the more bits we have, the better the

    brightness resolution

  • 8/2/2019 Part1 [Compatibility Mode]

    27/43

    27

    Electronic Engineering

    256

    Grey-level quantization

    3282

    Electronic Engineering

    Quantization Methods

    Uniform or linear - intensity of object is lineary mapped to gray-

    levels of image

    Logarithmic - higher intensity resolution in darker areas (the

    human eye is logarithmic)

    object intensity

    imageintensity

    object intensity

    imageintensity

  • 8/2/2019 Part1 [Compatibility Mode]

    28/43

    28

    Electronic Engineering

    Common Quantization Levels

    I(i,j) is given by integer values [0-max], max=2n-1

    n=1 [0 - 1] binary image

    n=5 [0 - 31] maximum the human

    eye can resolve (locally)

    n=8 [0 - 255] 1 byte, very common

    n=16 [0 - 65535] common in research

    n=24 [0 - 16.2*106] common in color images

    (i.e. 3*8 for RGB)

    Electronic Engineering

    Choice of Sampling andQuantization

    What will the image be used for?

    What are the limitations in memory and speed?

    Will the image only be used for visual

    interpretation or for any imageanalysis/processing?

    What information is relevant for the analysis (i.e.

    color, spatial and/or graylevel resolution)?

  • 8/2/2019 Part1 [Compatibility Mode]

    29/43

    29

    Electronic Engineering

    Road Map

    Digital image representation

    Sampling

    Quantization

    Colour spaces

    Colour images

    Electronic Engineering

    Light as a Waveform

    Light can be split into its component wavelengths andintensity

    The wavelength of visible light lies roughly between 400nmand 700nm

    these measurements can be combined into a spectral

    power distribution (SPD) a description of how the intensity of light from some

    particular source varies with wavelength

    The SPD for some light source corresponds closely to itscolour components:

    short wavelength (440nm) = blue

    medium (550) = green

    long (590) = red

  • 8/2/2019 Part1 [Compatibility Mode]

    30/43

    30

    Electronic Engineering

    Tristimulus Theory of

    Colour Vision

    This theory states that human perception of colour derives

    from the eyes responses to three different groups of

    wavelengths

    i.e. those corresponding to red, green and blue (RGB)

    Electronic Engineering

    Tristimulus Theory of

    Colour Vision

    Therefore: any sensation of colour can be produced bymixing together suitable amounts of these colours

    Red, Green & Blue are called theadditive primarycolours

    Although this is broadly true, the operation of the receptorsin the eye is not quite that simple:

    the receptors inter-operate in a more complex way for somevisible colours

    therefore it is notpossible to represent any visible colour asa combination or R, G & B

  • 8/2/2019 Part1 [Compatibility Mode]

    31/43

    31

    Electronic Engineering

    Color in Images and Video

    Light and Spectrum: visible light is an electro-

    magnetic wave in the 400 nm - 700 nm range.

    Most light we see is not one wavelength, it's acombination of many wavelengths

    Electronic Engineering

    The Human Retina Simple Model-

    The eye functions on the same principle as a camera

    Each neuron is either a rod or a cone.

    The rods contain the elements that are sensitive to light intensities. Rods are

    not sensitive to color.

    Cones come in 3 types: red, green and blue. Each responds differently to

    various frequencies of light.

  • 8/2/2019 Part1 [Compatibility Mode]

    32/43

    32

    Electronic Engineering

    Properties of the Human Visual

    System

    The eye is more sensitive to changes in brightness thancolour

    The eye is unable to perceive brightness levels above orbelow certain thresholds

    The eye cant distinguish minor changes in brightness orcolour. Certain ranges of brightness or colour are more

    important visually than others. E.g. eye is more sensitive to minor changes in shades of

    green than other colours

    Sensitivity of the eye is not linear.

    Electronic Engineering

    Color Composition

    A color can be specified as the sum of three colors. So colorsform a 3 dimensional vector space.

    The following figure shows the amounts of three primaries

    needed to match all the wavelengths of the visible spectrum.

  • 8/2/2019 Part1 [Compatibility Mode]

    33/43

    33

    Electronic Engineering

    Hue distinguishes among colors such as red, green,

    purple, and yellow

    Saturation refers to how pure the color is, how much

    white/gray is mixed with it

    red is highly saturated; pink is relativelyunsaturated

    royal blue is highly saturated;

    sky blue is relatively unsaturated

    pastels are less vivid, less intense

    Chromatic Color

    Lightness embodies the achromatic notion of perceived intensity

    of a reflecting object

    Brightness is used instead of lightness to refer to the perceived

    intensity of a self-luminous (i.e., emitting rather than reflecting

    light) object, such as a light bulb, the sun, or a CRT

    Can distinguish ~7 million colors when samples placed side-by-side (JNDs)

    about 128 fully saturated hues are distinct

    eye less discriminating for less saturated light (from16 to 23 saturation steps for fixed hue and lightness),and less sensitive for less bright light

    Chromatic Color

  • 8/2/2019 Part1 [Compatibility Mode]

    34/43

    34

    Electronic Engineering

    Occurs with inks for print medium, paints that absorb light. In

    subtractive mixture, the light passed by two filters (or reflected

    by two mixed pigments)

    Subtractive Mixture

    blue green yellow red

    green

    Electronic Engineering

    Used to mix R, G, B guns of CRT. The figure shows two

    projectors throwing pure blue and yellow filtered light upon the

    same portion of the screen. In contrast to what happens in a

    subtractive mixture, the result of adding these two colors is gray.

    Additive Mixture

  • 8/2/2019 Part1 [Compatibility Mode]

    35/43

    35

    Electronic Engineering

    These complementary unique hues play a role in

    opponent color perception discussed later

    Note that only for perfect red and green do you get gray

    Complementary Hues

    Electronic Engineering

    The gray patches on the blue and yellow backgrounds arephysically identical. But they do not look similar

    Color Contrast

  • 8/2/2019 Part1 [Compatibility Mode]

    36/43

    36

    Electronic Engineering

    Hardware-oriented models: not intuitive

    RGB, used with color CRT monitors

    YIQ, the broadcast TV color system

    CMY (cyan, magenta, yellow) for color printing

    CMYK (cyan, magenta, yellow, black) for colorprinting

    User-oriented models

    HSV (hue, saturation, value) also called HSB (hue,saturation, brightness)

    HLS (hue, lightness, saturation)

    The Munsell system

    CIE Lab

    Color Models

    Electronic Engineering

    Color Models for Images (I)

    RGB Additive Model: A color image is a 2-D

    array of (R,G,B) integer triplets. These triplets

    encode how much the corresponding phosphor

    should be excited in devices such as a monitor.Blue Cyan

    Red Yellow

    Green

    Magenta

    Black(0,0,0)

    White(1,1,1)

  • 8/2/2019 Part1 [Compatibility Mode]

    37/43

    37

    Electronic Engineering

    Main diagonal => gray levels

    black is (0, 0, 0)

    white is (1, 1, 1)

    RGB Color Model

    Electronic Engineering

    Color Models for Images (II)

    BlueCyan

    RedYellow

    Green

    Magenta

    Black(1,1,1)

    White(0,0,0)

    CMY Subtractive Model: Cyan, Magenta, and Yellow(CMY) are complementary colors of RGB.

    CMY model is mostly used in printing devices where the colorpigments on the paper absorb certain colors (e.g., no red light

    reflected from cyan ink)

  • 8/2/2019 Part1 [Compatibility Mode]

    38/43

    38

    Electronic Engineering

    Used in electrostatic and in ink-jet plotters that deposit pigment onpaper

    Cyan, magenta, and yellow are complements of red, green , andblue

    Subtractive primaries: colors are specified by what is removed orsubtracted from white light, rather than by what is added toblackness

    Cartesian coordinate system

    Subset is unit cube

    white is at origin, black at (1, 1, 1):

    The CMY(K) Color Model

    B

    G

    R

    Y

    M

    C

    1

    1

    1

    Electronic Engineering

    In the CMY model colours are specified by what is removed(absorbed) from white light, rather than by what is added toblackness.

    C + M + Y at full intensity = Black

    Subtractive scheme: E.g.Cyan objects absorb red, so cyan is whiteminus red (or blue + green)

    C = G + B = W - R

    M = R + B = W - G

    Y = R = G = W - B

    To obtain a good black for printing, another primary isadded: K (CMYK)

    The CMY(K) Color Model

  • 8/2/2019 Part1 [Compatibility Mode]

    39/43

    39

    Electronic Engineering

    Color Models (IV)

    YUV Model: Human perception is more sensitive to brightnessthan chrominance. Therefore, instead of separating colors, one canseparate the brightness info. from the color info.

    Y is luminance

    Y = 0.299R + 0.587G + 0.114B

    Chrominance is defined as the difference between a color and areference white at the same luminance. It can be represented by Uand V -- the color differences.

    U = B - Y

    V = R - YEye is most sensitive to Y. Therefore, any error in the resolution of theluminance (Y) is more important than the chrominance (U,V) values.

    In PAL, 5 (or 5.5) MHz is allocated to Y, 1.3 MHz to U and V.

    HSV models colour in terms of:

    HUE:

    the dominant wavelength, i.e. where most of the energy of thelight is concentrated.

    hues usually identified by names: mixtures of red, yellow,green and blue.

    SATURATION

    a measure of the colours purity or intensity:

    the presence of other hues makes the colour paler

    BRIGHTNESS

    a measure of how light or dark the colour is.

    HSV corresponds more closely to the way humans think about

    colour than RGB.

    Color Models (VI)

  • 8/2/2019 Part1 [Compatibility Mode]

    40/43

    40

    Electronic Engineering

    Hue, saturation, value (brightness)

    Hexcone subset of cylindrical (polar) coordinate system

    The V = 1 plane contains the RGB models R = 1, G = 1, B = 1, inthe regions shown

    The HSV Color Model

    Electronic Engineering

    Hue, lightness, saturation. Double-hexcone subset

    Maximally saturated hues are at S = 1, L = 0.5

    The HLS color Model

  • 8/2/2019 Part1 [Compatibility Mode]

    41/43

    41

    Electronic Engineering

    Munsell color-order system

    set of samples in 3D space

    hue, value/lightness, chroma (saturation)

    equal perceived distances between neighbors

    Defining Color

    Electronic Engineering

    Munsell color definition

    Black

    Grays

    White Tints Purecolor

    Tones

    Shades

    Decrease saturation

    Decrease

    lightness

  • 8/2/2019 Part1 [Compatibility Mode]

    42/43

    42

    Electronic Engineering

    Road Map

    Digital image representation

    Sampling

    Quantization

    Colour spaces

    Colour images

    Electronic Engineering

    Channels in Colour Images

    Blue Channel of Image

    1 sample per pixel

    Green Channel of Image

    1 sample per pixel

    Red Channel of Image

    1 sample per pixel

    3 samples per pixel

  • 8/2/2019 Part1 [Compatibility Mode]

    43/43

    Electronic Engineering

    Colour Vs. Grey

    Electronic Engineering

    Colour Vs. B&W