Computing Theory

Embed Size (px)

Citation preview

  • 8/20/2019 Computing Theory

    1/31

    GCIT 1007 - IT and Digital MediaLecture 2 – Image I

  • 8/20/2019 Computing Theory

    2/31

    Page 2

    To Print a Large Banner 

    You want to print a large banner of Hong Kong Baptist University

    You download the logo from BU's website, is it OK?

    The image turns out to be

    very chunky when enlarged

    • The vector version will

    give you better quality

  • 8/20/2019 Computing Theory

    3/31

    Page 3

    Today’s Outline

    Bitmap vs. Vector 

    Image Compression (run length)

    Color models

  • 8/20/2019 Computing Theory

    4/31

    Page 4

    Representation of Bitmap images

     Also called raster images

    Made up of pixels (tiny dots of individual color) in a grid

    a pixel

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    245

    245

    245

    223

    223

    223

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    200

    199

    193

    108

    107

    71

    101

    99

    38

    117

    115

    24

    138

    135

    20

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    255

    232

    232

    232

    100

    99

    61

    142

    139

    13

    243

    238

    0

    255

    250

    0

    255

    250

    0

    255

    250

    0

    255255

    255

    255255

    255

    255255

    255

    255255

    255

    213212

    207

    8684

    30

    229224

    0

    255250

    0

    255250

    0

    255250

    0

    255250

    0

    255250

    0

    255

    255

    255

    255

    255

    255

    255

    255

    255

    233

    233

    233

    90

    88

    31

    246

    241

    0

    255

    250

    0

    255

    250

    0

    255

    250

    0

    255

    250

    0

    255

    250

    0

    255

    250

    0

    255

    255

    255

    255

    255

    255

    255

    255

    255

    98

    97

    60

    231

    226

    0

    255

    250

    0

    255

    250

    0

    255

    250

    0

    255

    250

    0

    255

    250

    0

    255

    250

    0

    255

    250

    0

    ::

    What is inside the file?

  • 8/20/2019 Computing Theory

    5/31

    Page 5

    Representation of Vector images

    Made up of a collection of lines, curves and shapes

     And editable attributes such as color and outline

    These information are written in graphics language like SVG

    What is inside the file?

  • 8/20/2019 Computing Theory

    6/31

    Page 6

    • Zigzag edges becomenoticeable when an image isenlarged as pixels arerectangular shape

    • Printing / displaying qualitydepends on resolution

    - number of pixels in animage

    - printing / screen resolution

    • Not restricted to arectangular shape

    • Resolution independent

    Bitmap vs. Vector Scalability

    Bitmap Vector  

  • 8/20/2019 Computing Theory

    7/31

    Page 7

    Bitmap vs. Vector File Size

    • File size is usually large

    - Must record the value of everypixel, one by one

    - Many repeated information ifpixels are having the samecolors

    Bitmap

    • File size is usually small- Information is more

    compact

    Vector 

    File size

    = total no. of pixels

    x no. of bytes used to

    represent a color= 100 x 120 x 3

    = 36000 bytes

    100 pixels

    120 pixels

    File size = 86

    bytes

  • 8/20/2019 Computing Theory

    8/31

    Page 8

    Bitmap vs. Vector Editable Components

    • Not easy to edit

    Bitmap

    • Components can be editedindependently

    Vector 

  • 8/20/2019 Computing Theory

    9/31

    Page 9

    • DO NOT inherently supporttransparency

    • Transparency depends onfile type

    • Transparent, no background

    Bitmap vs. Vector Transparency

    Bitmap Vector  

  • 8/20/2019 Computing Theory

    10/31

    Page 10

    • Mainly for Photo-realisticimages

    • Images are usually made upof solid areas of color orgradients, but they CANNOTdepict the continuous subtle

    tones of a photograph• Mainly for logo / cartoon-like

    designs and drawing

    Bitmap vs. Vector Usage

    Bitmap Vector  

  • 8/20/2019 Computing Theory

    11/31

    Page 11

    • All images from digitalcameras and all scannedimages are bitmaps

    • Vectorization- convert bitmap to vector

    format

    - e.g. Trace Bitmap in Flash

    Bitmap

    Bitmap vs. Vector Conversion

    • Fonts are vector objects

    • Rasterizing

    - Convert vector to bitmap

    - e.g. Rasterize Type inPhotoshop

    Vector 

  • 8/20/2019 Computing Theory

    12/31

    Page 12

    • Microsoft Paint

    • Adobe Photoshop

    • Gimp

    :

    :

    :

    • Adobe Illustrator 

    • CorelDRAW

    • Inkscape

    :

    :

    :

    Bitmap vs. Vector Editing Tools

    Bitmap Vector  

  • 8/20/2019 Computing Theory

    13/31

    Page 13

    Bitmap vs. Vector Summary

    Bitmap Vector 

    Representation pixels geometry objects

    Scalability

    File Size

    Editable Component

    Transparency

    Usage photologo / design /

    drawing

  • 8/20/2019 Computing Theory

    14/31

    Page 14

    IMAGE COMPRESSION

  • 8/20/2019 Computing Theory

    15/31

    Page 15

    How to store an image?

    Consider the images contain only black and white, not grayscale.

    How to store thispicture in computer or

    other electronic

    devices?

  • 8/20/2019 Computing Theory

    16/31

    Page 16

    Digitization

    Image is partitioned into small grids

    We use 1 to represent a black grid and 0 to represent a whitegrid

    The grid lines are just for reference, not

    in the original image

  • 8/20/2019 Computing Theory

    17/31

    Page 17

    Compression?

    Given this data, we can

    save the data from left to

    right, then from top to

    bottom

    It takes 10 x 10 = 100 bits

    Can we compress it?

    10

    10

  • 8/20/2019 Computing Theory

    18/31

    Page 18

    Solution

    COUNT the number of consecutive 0, then the number of consecutive 1…

    54, 2, 7, 4,

    5, 2, 2, 2,3, 8, 1, 10

  • 8/20/2019 Computing Theory

    19/31

    Page 19

    Run-length Encoding

    If we use 6 bits to represent each number, it takes us

    12 x 6 = 72 bits !!!

    100 – 72 = 28 bits are saved!!!

    54, 2, 7, 4,5, 2, 2, 2,

    3, 8, 1, 10

    54 110110

    2 000010

    7 000111

    .. …

  • 8/20/2019 Computing Theory

    20/31

    Page 20

     Applications of Run-length Encoding

    Fax machines

    Since letter contains lots of white

    space, run-length encoding is

    very effective in Fax machine

     Also used in

    BMP, PCX, PICT files

  • 8/20/2019 Computing Theory

    21/31

    Page 21

    Decoding

    110110

    000010000111

    54, 2, 7, 4,

    5, 2, 2, 2,3, 8, 1, 10

    Data

    Information

  • 8/20/2019 Computing Theory

    22/31

    Page 22

    Further Improvement?

    Can we? Yes!!!

    Use 5 bits to present each number.

    Because 6 bits are not necessary for most numbers

     – E.g. 2 = 10(2) , 7 = 111(2)

    Space can be saved with 5 bit representation

  • 8/20/2019 Computing Theory

    23/31

    Page 23

    Further Improvement?

    But how about 54?

    54 = 110110 (2)   – 6 bits are needed to represent the whole number 

    The trick is:

    54   31, 0, 23

    11111, 00000, 10111

    Then the sequence becomes

     – 31, 0, 23, 2, 7, 4, 5, 2, 2, 2, 3, 8, 1, 10

    So it takes 14 x 5 = 70 bits. < 72!!

  • 8/20/2019 Computing Theory

    24/31

    Page 24

    Other Compression Methods

    JPEG is using Predictive DCT (Discrete Cosine Transform)

     – A lossy compression method

    GIF is using LZW

     – Patented of Abraham Lempel, Jacob Ziv, and Terry Welch

     – A lossless compression method

    PNG is using Phil Katz Deflate compression method

     – Phil Katz is famous for creating the PKZIP program

    DCT, LZW and PK Deflate are too complex to be covered here

  • 8/20/2019 Computing Theory

    25/31

    Page 25

    COLORS

  • 8/20/2019 Computing Theory

    26/31

    Page 26

    RGB Color Model

    Three primary colors, RGB (Red, Green, Blue), mixed up in different

    proportions to produce all of the possible colors

     Adding color light beams but NOT adding paint

     An additive color model

     – White is the additive combination of ALL primary colored light

     – Black is the absence of light For Display Monitors

  • 8/20/2019 Computing Theory

    27/31

    Page 27

    RGB Color Model

    How much Red, Green and Blue?

    3 numbers (each range from 0 to 255)

    for the amount of RGB

    255, 0, 0 0, 255, 0 255, 255, 0

    0, 0, 255

    0, 255, 255255, 0, 255

    0, 0, 0

    255, 255, 255

    For a RGB System, 8 bits

    for each of the R, G an BTotally 8 + 8 + 8 = 24 bits of

    different colors, known as

    true colors ( 16,777,216

    colors)

    In Windows, true color is 32

    bits as there is 8 bits

    allocated for the alphachannel for “transparency”

    value (RGBA)

  • 8/20/2019 Computing Theory

    28/31

    Page 28

    CMYK Color Model

    Combining four colors: Cyan, Magenta, Yellow, and Key (blacK)

    Each component measured in percent from 0 to 100

    Possible to achieve a large range of colors

     Adding paint

     – White is the natural color of the paper / background

     – Black results from a full combination of ALL colored inks

     A subtractive color model

     – Use reflected light to display color 

    For Color Printing

  • 8/20/2019 Computing Theory

    29/31

    Page 29

    HSB Color Model

    Three fundamental properties of color 

    For old color TV

    (non-HD TV)

    Hue• Color 

    • Measured in degrees from

    0 to 360• 0 is red, 60 is yellow,

    120 is green, 180 is cyan,

    240 is blue, 300 is magenta

    Saturation• Purity: the amount of pure

    color mixed with white color 

    • Measured in percent from

    0 to 100

    • The higher the percentage,the more pure the color 

    Brightness• Intensity: the amount of pure

    color mixed with black color • Measured in percent from 0 to

    100

    • The higher the percentage,

    the brighter the color 

  • 8/20/2019 Computing Theory

    30/31

    Page 30

    Color Depth

    Number of bits to describe the

    color of one pixel in a bitmap file

    More number of bits used

     – more possible colors can be represented

     – larger file size

    n bits = 2n colors

    24 bits – millions of colors

    4 bits – 16 colors

    1 bit – only black or white

  • 8/20/2019 Computing Theory

    31/31

    Page 31

    GCIT1007 IT and Digital Media, Spring 2015

     All copyright and intellectual property rights, without limitation, are retained byDepartment of Computer Science, HKBU (http://www.comp.hkbu.edu.hk).

    References

    J. Straubhaar, R. LaRose, L. Davenport, Media

    Now: Understanding Media, Culture, and

    Technology, 7th Edition, Wadsworth Publishing,

    2012. Nigel Chapman and Jenny Chapman, Digital

    Multimedia, 3rd Edition, Wiley, 2011.