51
Digital Images ENGG1015 1 st Semester, 2010 Dr. Hayden Kwok-Hay So Department of Electrical and Electronic Engineering

Digital Images - University of Hong Kong

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Digital Images - University of Hong Kong

Digital Images

ENGG1015

1st Semester, 2010

Dr. Hayden Kwok-Hay So

Department of Electrical and Electronic Engineering

Page 2: Digital Images - University of Hong Kong

Back to top-level

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 2

Applications

Systems

Digital Logic

Circuits

Electrical Signals

High Level

Low Level

•  Computer & Embedded Systems •  Computer Network •  Mobile Network

•  Image & Video Processing

•  Combinational Logic •  Boolean Algebra

•  Basic Circuit Theory

•  Voltage, Current •  Power & Energy

This week

Page 3: Digital Images - University of Hong Kong

Back to top-level

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 3

Applications

Systems

Digital Logic

Circuits

Electrical Signals

High Level

Low Level

•  Computer & Embedded Systems •  Computer Network •  Mobile Network

•  Image & Video Processing

•  Combinational Logic •  Boolean Algebra

•  Basic Circuit Theory

•  Voltage, Current •  Power & Energy

This week

Page 4: Digital Images - University of Hong Kong

Digital Images

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 4

Representation

Processing Hardware

Page 5: Digital Images - University of Hong Kong

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 5

Page 6: Digital Images - University of Hong Kong

Representing Images

bitmap

R G B

pixel

An image is broken down into small regions called picture elements (pixels)

Bitmap: A pixel-by-pixel representation of image

1st semester, 2010 6 Digital Images - ENGG1015 - Dr. H. So

Page 7: Digital Images - University of Hong Kong

Image Dimensions   Image Size

•  The number of pixel in X-Y direction •  Sometimes quoted using the total number of pixels in a

picture (N megapixels)

  Image Resolution •  The density of pixels •  Measured by pixel-per-inch (PPI)

15

14

1st semester, 2010 7 Digital Images - ENGG1015 - Dr. H. So

Page 8: Digital Images - University of Hong Kong

Representing Pixels   Each pixel is represented by one or more

values   Black & white images:

•  Each pixel is represented by exactly 1 value (B or W)

•  1 bit is enough to represent 2 possible values   Grey scale images:

•  Each pixel is usually a byte, keeping the brightness or gray levels

  Color images: •  Each pixel represented a group of color

components of that location •  Different color systems: RGB, CYMK, YCbCr, etc

1st semester, 2010 8 Digital Images - ENGG1015 - Dr. H. So

Page 9: Digital Images - University of Hong Kong

Monochrome and Gray-scale Images

  Monochrome Image

  Each pixel is 1 bit, either 0 or 1

  Dithering is used to produce different intensities

  Gray-scale Image

  Each pixel is usually a byte (8-bit), keeping the brightness or gray levels

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 9

B&W B&W (w/ dither) Grayscale

Page 10: Digital Images - University of Hong Kong

Color Images

  indexed color image   # of color support

depends on the # of bit for each pixel •  4 bits 16 colors •  8 bits 256 colors

  Color Look-Up Tables (LUTs)

  Color palette

  24-bit color image   Each pixel is

represented by 3 bytes using a certain color model

  Supports 256x256x256 colors •  16 million colors

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 10

16 colors 256 colors 16M colors

Page 11: Digital Images - University of Hong Kong

RGB Color Model   Additive color model   Primary colors: Red, Green,

and Blue   Secondary colors obtained by

additive mixing of primary colors

  Commission Internationale d'Eclairage (CIE) specifies red to be 700nm, green to be 546.1nm and blue to be 435.8nm

  Used in media that transmit light (e.g. TV)

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 11

Page 12: Digital Images - University of Hong Kong

CMY Color Model   Subtractive color model   Subtractive primaries:

Cyan, magenta, and yellow

  A subtractive primary absorbs a primary color and reflects the other two •  E.g. Cyan absorbs red and

reflect blues and green

  Used in printing device

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 12

Page 13: Digital Images - University of Hong Kong

Printing an Image   Print Size

•  Depends on the mapping between printer’s resolution, image resolution & image size

•  A Printer’s printing resolution is usually higher than an image’s resolution because multiple dots of ink are needed to created color of an image pixel

  Color Space •  On screen display: RGB (additive) •  Printing devices: CMYK (subtractive)

  Color Production •  Each pixel may have different color •  Each ink drop has only 1 color

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 13

Page 14: Digital Images - University of Hong Kong

Dithering   Create the illusion of new colors and shades by

varying the pattern of dots. •  E.g. Newspaper photographs are dithered. If you

look closely, you can see that different shades of gray are produced by varying the patterns of black and white dots. There are no gray dots at all.

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 14

Page 15: Digital Images - University of Hong Kong

Dither, Halftone, Grayscale

original dither halftone

1st semester, 2010 15 Digital Images - ENGG1015 - Dr. H. So

Page 16: Digital Images - University of Hong Kong

RGB Color Space

  The RGB model describes the formation of color by mixing different portion of Red, Blue and Green light.

  But what is “red”, “blue” and “green”? •  E.g. which of the colors on top of this page is

“red”?   A color space defines objectively the exact

color that is represented numerically so the same information may be reproduced on different machines.

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 16

Page 17: Digital Images - University of Hong Kong

sRGB color space  Originally defined by HP and Microsoft  Now the de facto standard on the Internet

and most consumer electornics •  Digital camera, HDTV, computer monitors, etc

  If a color profile is not specified, the default assumption is that the colors are specified in sRGB color space

 Given the specification of the 3 primary colors (R, G, B), the colors representable will be the color triangle spanned from the three colors.

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 17

Page 18: Digital Images - University of Hong Kong

Common Color Spaces

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 18

Page 19: Digital Images - University of Hong Kong

More Color Models   Both RGB and CMY(K) model specify how to

form a color   But they have little resemblance to how human

beings reason about colors   E.g. How do you get the RGB values of the

pale orange color on the right?

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 19

[R G B] = [204 131 42]

[R G B] = [? ? ?]

[248 215 152]

Page 20: Digital Images - University of Hong Kong

HS(B/V), HSL, HSI Color Model   The family of HSx models describe colors

similar to how human perceives colors •  Also similar to how painters create colors

 HSB: Hue Saturation Brightness  HSV: Hue Saturation Value  HSL: Hue Saturation Lightness  HSI: Hue Saturation Intensity  Similar, but often comes with confusing (or

even contradicting) definitions

Page 21: Digital Images - University of Hong Kong

Cylindrical-Coordination   Hue:

•  The dominant color •  The angle away

from red   Saturation

•  The amount away from the center

•  How “full” the color is

  Lightness/Brightness/Value •  The amount of

white/black added

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 21

Page 22: Digital Images - University of Hong Kong

More Image Representations?  Raster image (bitmap image) - Raster

graphics uses pixel values to describe an image. The file size is independent of the image complexity. For higher resolution, the file size increases dramatically

 Vector graphics (draw graphics) - An alternate approach is to use only instructions for drawing lines, circles, ellipses, curves, and other shapes.

Page 23: Digital Images - University of Hong Kong

Vector Graphics  Vector-based images are composed of

key points and paths which define shapes, and coloring instructions, such as line and fill colors.

 Example:

Page 24: Digital Images - University of Hong Kong

Vector Graphics Advantages   Vector graphics can be scaled up and down

easily and quickly while retaining the quality of the picture. Raster images scale poorly and display poorly at resolutions other than that for which the image was originally created.

  Vector graphics require less bandwidth and can be accessed and viewed faster than raster graphics.

  Vector graphics can be edited and manipulated far easier than raster images.

Page 25: Digital Images - University of Hong Kong

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 25

Page 26: Digital Images - University of Hong Kong

Image Processing

 Used in digital camera, TV, cell phones…

 Used in all kinds of photo editing SW •  e.g. Photoshop, GIMP…

Page 27: Digital Images - University of Hong Kong

Image Processing - Examples

Original Greyscale

Blur Edge Detection

Page 28: Digital Images - University of Hong Kong

RGB to Grey-scale Conversion  Each pixel of a grey-scale image has only

one intensity value, V

 High V: white, Low V: black

 Easiest conversion:

 Produce better result if you weight G and R more than B •  Human eyes are more sensitive to green and red €

V =R +G + B

3

Page 29: Digital Images - University of Hong Kong

Basic Filtering: Matrix Convolution   Filters are building blocks of image processing

systems   One of the most basic filtering method is by matrix

convolution

y[r,c] =1h[i, j]

i, j∑h[ j,i]x[r − j,c − i]

i=−1

1

∑j=−1

1

∑r

c

Page 30: Digital Images - University of Hong Kong

Matrix Convolution in Action

12 8 27 26 54 48 14 9 16 8 29 9 3 11 10 15 50 60 8 12 34 2 29 52

17 2 44 35 56 72 22 39 43 34 63 77

1 2 1 2 4 2 1 2 1

9 16 8 11 10 15 12 34 2

1 × + 2 × + 1 × 2 × + 4 × + 2 × 1 × + 2 × + 1 ×

+ + = 14

14 19

16 8 29 10 15 50 34 2 29

19

X H Y

34

34 8 29 9 15 50 60 2 29 52

Page 31: Digital Images - University of Hong Kong

Gaussian Blur   A simple but effective way to blur a picture   Each pixel is replaced with a weighted sum of the

values of its surrounding pixels   The weighting factors have a Gaussian distribution,

thereby the name   Intuitively: each pixel is mixed to certain extent with

its neighbors

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 31

2 4 5 4 2

4 9 12 9 4

5 12 15 12 5

4 9 12 9 4

2 4 5 4 2

Page 32: Digital Images - University of Hong Kong

Edge Detection   Useful in understanding an image

•  For robot, face recognition, medical imaging etc

  In a smooth contour, the pixel values usually do not change rapidly

  However, the pixel exhibit sudden jump in values near an edge •  E.g. jump from 1 to 130

  Sobel edge detection is one of the simplest algorithms that makes use of this observation to find edges •  Compares values of the neighbors of pixel

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 32

Page 33: Digital Images - University of Hong Kong

Sobel filter

 Sobel filter use the results of two filters •  In x and y direction

 Magnitude of the resulting pixel as:

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 33

-1 0 +1

-2 0 +2

-1 0 +1

Gx

+1 +2 +1

0 0 0

-1 -2 -1

Gy

G = Gx2 +Gy

2

G ≈ Gx + Gy Easier to compute

Page 34: Digital Images - University of Hong Kong

Sobel Filter Example – x Dir

3 3 3 39 39 39 3 3 3 40 40 40 3 3 3 41 41 41 3 3 3 42 42 42 3 3 38 41 41 41 3 3 37 40 40 40

-1 0 1 -2 0 2 -1 0 1

3 3 3 3 3 3 3 3 3

-1 × + 0 × + 1 × -2 × + 0 × + 2 × -1 × + 0 × + 1 ×

+ + = 0

0 152

3 3 40 3 3 41 3 3 42

152

X H Y

152

152 3 40 40 3 41 41 3 42 42

Page 35: Digital Images - University of Hong Kong

Sobel Filter Example – x Dir

3 3 3 39 39 39 3 3 3 40 40 40 3 3 3 41 41 41 3 3 3 42 42 42 3 3 38 41 41 41 3 3 37 40 40 40

-1 0 1 -2 0 2 -1 0 1

X H Y 0 0 148 148 0 0

0 0 148 148 0 0

0 0 152 152 0 0

0 0 154 154 0 0

0 0 152 152 0 0

0 0 152 152 0 0

Page 36: Digital Images - University of Hong Kong

Image Processing Summary   Image processing is the task of

manipulating the image by mathematical means to achieve high level requirements

 Common operations: filtering  Many other operations:  E.g. Image forensic, Lithography,

medical imaging, automatic image diagnosis, robot control, etc…

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 36

Page 37: Digital Images - University of Hong Kong

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 37

Page 38: Digital Images - University of Hong Kong

Digital Cameras   Resolution measured in pixels H x V

  Image sensing: charge coupled device (CCD)

  Megapixels is used to denote the total max pixels in the image •  E.g. 5 Megapixel - in the 2520 by 1890 and higher

pixel range. Photo quality 11 x 14 prints from this class of camera.

  Comparing film cameras to digital cameras is difficult since resolution is measured differently

Page 39: Digital Images - University of Hong Kong

Taking Pictures 1. Image captured by lens 2. Image focuses on CCD 3. CCD generates analog

representation of image 4. Analog signal converts to

digital 5. Digital signal processing

(DSP) adjust quality, etc Step 5

Step 4

Step 3

Step 1

Step 2

Page 40: Digital Images - University of Hong Kong

Marketing Caveats  Q: For digital cameras, higher

“megapixel” value always produce better photos?

 A: Not really. If you will only look at the photos on websites, or will only print them on 3R papers, you don’t need all the pixels from a 10M pixels camera.

Page 41: Digital Images - University of Hong Kong

Area You Ready?

Page 42: Digital Images - University of Hong Kong

Flat Panel TVs and Monitors   Pictures displayed as matrix of pixels on screen   Two major technologies for generating picture

•  Plasma •  Liquid Crystal Display (LCD)

  Plasma •  Neon-Xenon gas trapped between two glasses •  When electrically charged, each pixel display red,

blue or green color.   LCD

•  Liquid crystal between glasses pass/block light depending on electrical signal

•  Pass corresponding backlight

Page 43: Digital Images - University of Hong Kong

LED TVs?  Misleading term

 Proper name: LED-backlight LCD TVs

 Use the same LCD display technology as all other “LCD displays”.

 Most other standard “LCD displays” use cold cathode fluorescent light (CCFL) for backlight

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 43

Page 44: Digital Images - University of Hong Kong

Three Characteristic Dimensions  Panel Size •  The physical dimension of the panel •  A 42” panel has a diagonal measurement of

42”  Display Resolution •  The number of picture-elements (pixels) along

each X-Y direction  Dot Pitch •  The distance between two pixel of the screen

Panel Size = Display Resolution * Dot Pitch

Page 45: Digital Images - University of Hong Kong

Standard Display Resolutions

Page 46: Digital Images - University of Hong Kong

Marketing Caveats  Q: For flat panel TVs, a bigger screen

always produce better display than a smaller screen?

 A: Not really. It depends on the distance you will be watching the TV and the TV source signal.

Page 47: Digital Images - University of Hong Kong

More Pixel = Good?   Human eye can identify 120 pixels per degree

of visual arc •  i.e. if 2 dots are closer than 1/120 degree, then our

eyes cannot tell the difference   At a distance of 2m (normal distance to a TV)

our eyes cannot differentiate 2 dots 0.4mm apart.

  Closer to TV => easier to differentiate pixels   Far away => cannot tell the difference

screen

Minimum: 2 arc minute

Page 48: Digital Images - University of Hong Kong

Image courtesy of www.carltonbale.com

Page 49: Digital Images - University of Hong Kong

Source: http://www.diamond-vision.com/quad_dot_pattern.asp

True LED displays  Each pixel is a

LED

 Used mostly in outdoor, large- scale displays

Page 50: Digital Images - University of Hong Kong

Dallas Cowboys Stadium Sideline Display 48.64m x 21.76m Pixel Pitch: 20mm Displays World’s Largest High-Definition Video Display

Hong Kong Shatin Racecourse 70.4m x 8m World’s Longest TV screen

Page 51: Digital Images - University of Hong Kong

In Conclusion…  Digital signal processing is a very broad

field within EEE  The processing of digital image is a

good example of high-level applications that run on digital signal processing systems.

 To display and process digital images correctly, you need the right combination of image representation, hardware, and processing power.

1st semester, 2010 Digital Images - ENGG1015 - Dr. H. So 51