1. introduction computer engineering, sejong university...

37
Image Processing 1. Introduction Computer Engineering, Sejong University Dongil Han 2/74 What is Image Processing? Science of manipulating a picture Enhance or distort an image Highlight certain features of an image Create a new image from portions of other images Restore an image that has been degraded

Upload: vanthien

Post on 10-Sep-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

Image Processing

1. Introduction

Computer Engineering, Sejong University

Dongil Han

2/74

What is Image Processing?

Science of manipulating a picture

• Enhance or distort an image

• Highlight certain features of an image

• Create a new image from portions of other images

• Restore an image that has been degraded

Page 2: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

3/74

Median Filtering

4/74

Subtraction operation

Page 3: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

5/74

Original Image

6/74

Negative Image

Page 4: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

7/74

Left Image

8/74

Right Image

Page 5: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

9/74

Depth Map

10/74

Wiener Filter

Page 6: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

11/74

Image Processing vs. Computer Graphics

They are companion technologies

Computer graphics

• The generation of synthetic images

• Works with 2-D, 3-D objects

Image processing

• Manipulation of images that have already been captured or generated

12/74

Graphic images

Page 7: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

13/74

Image based rendering

Original image User marked edge Generated image

14/74

Four basic classifications

Point processing• Modifies a pixel’s value based on that pixel’s original value

or position

Area processing• Modifies a pixel’s value based on its original value and the

values of neighboring pixels

Geometric processing• Change the position or arrangement of the pixels

Frame processing• Generate pixel values based on operations on two or more

images

Page 8: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

15/74

Four basic classifications

Point processing example Area processing example

Geometric processing example Frame processing example

16/74

Image Processing Applications

Science and Space• NASA research projects provided millions of images

Movies• Image composition• Morphing• Image Warping

The paperless office• Document image processing

Medical industry• X-rays, ultrasound, CT(computed tomography),

MRI(magnetic resonance imaging), etc.

Page 9: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

17/74

Warping example

18/74

Warping example

Page 10: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

19/74

Warping example

20/74Gamma-ray imaging

Image Processing Applications

Page 11: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

21/74

X-ray imaging

Image Processing Applications

22/74

Image Processing Applications

Wilhelm Rontgen(German, 1845~1923)

ElectromagneticSpectrum

First X-ray imagetaken 1895/12/22

Page 12: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

23/74

MRI images

Image Processing Applications

24/74

Image Processing Applications

Machine vision• Uses image processing and image analysis• Automated inspection• Extensively used in semiconductor manufacturing

Law enforcement• Fingerprint inspection• Iris recognition• Face recognition

Page 13: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

25/74

Image Processing Applications

26/74

Image Processing Applications

Page 14: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

27/74

Image Processing Applications

http://www.ri.cmu.edu/projects/project_320.html

28/74

Image Processing Applications

Page 15: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

29/74

Visual PerceptionStructure of the human eye

Cornea : 각막

Pupil : 동공

Iris : 홍채

Lens : 수정체

Retina : 망막

Fovea : 중심와

Blind Spot : 맹점

Optic Nerve : 시신경

BlindSpot

30/74

light

Five distinct element

• Photoreceptors

(rods and cones)

• Horizontal cells

• Bipolar cells

• Amacrine cells

• Ganglion cell

The Human Retina

Page 16: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

31/74

• Rods- respond to dim light for BW vision- respond to form and movement- do not contribute color vision

• Cones- provide daylight color vision- one of 3 spectral types: S(blue), M(green), L(red)- concentrated in the center of retina

Rods and Cones

Visual Perception

32/74

The left eye

Visual Perception

Page 17: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

33/74

Visual Perception

34/74

Visual Perception

Page 18: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

35/74

Blind Spot Test

Visual Perception

36/74

Spectral response of cones- see Figure 1.7

Visual Perception

Page 19: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

37/74

Visual Perception

S ML

Three types of Cones• S type : responds Short-wavelength of visible light• M type : responds Middle-wavelength of visible light• L type : responds Long-wavelength of visible light

Slightly different from conventional R, G, B color model

38/74

Simultaneous Contrast

Visual Perception

Page 20: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

39/74

Perceived Brightness

Visual Perception

40/74

Visual Perception

Brightness adaptation

Page 21: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

41/74

Optical Illusions

Visual Perception

42/74

Color representation

Color model(color space)• Way of representing colors and their relationship to each

other• Different image processing systems use different color

models TV camera, Display monitor : RGB color space Publishing industry : CMYK color space Broadcasting : YIQ color space HSI Color space : Hue(색상), Saturation(채도),

Intensity(명도) XYZ, LAB, YUV, YCbCr, etc.

Page 22: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

43/74

Color representationRGB color space

44/74

Color representation

CMYK color space• Primary color : cyan, magenta, yellow

CMY color spaceC = 1.0 – RM = 1.0 - GY = 1.0 - B

• CMYK color space Black(K) is added Black is more pure black than the combination of other

three colors Black ink is cheaper than colored ink K = min(C, M, Y)

Page 23: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

45/74

• Mixture of light (빛의 합성)– Additive primaries(가법혼색)– Red, Green, Blue– Color monitor

• Mixture of pigments (염료의 합성)

– Subtractive primaries(감법혼색)– Cyan, Magenta, Yellow– Color printer

Primary Color

46/74

HSI color space

More intuitive and perceptually relevant than RGB space

Hue(색상) : represents color spectrum– Color information such as green, orange, blue, etc.

Saturation (채도) : represents the purity of color– greater the saturation, further the color is from

gray/white/black– Magnitude of Saturation : Pink < Red

Intensity (명도) : represents the brightness of color– 0: black, 1 : white

Suitable for representing the surface color(표면색) of subjects

Page 24: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

47/74

RGB to HSI

GBif

GBifH

360

Conversion formulas from RGB to HIS :

Red : = 0o

Normalized RGB values between [0,1] is used.

2/12

1

)])(()[(

)]()[(5.0cos

BGBRGR

BRGR

)(3

1BGRI

)],,[min()(

31 BGR

BGRS

48/74

RGB, HSI Color Model

Page 25: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

49/74

HSI Color Model

50/74

HSI Color Example

Page 26: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

51/74

Color image and its components

52/74

Color representation

YCbCr color space• Y : encodes luminance information• Cb : encodes blueness information• Cr : encodes redness information

Y = 0.299R + 0.587G + 0.114BCb = -0.16874R – 0.33216G + 0.5BCr = 0.5R – 0.41869G – 0.08131B

• Separates the luminance from the color information• Widely used in JPEG, MPEG compression• There are several ways to convert to/from YCbCr

Page 27: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

53/74

Image capture

Image capturing device• Photo diode : 0-D sensor, Output voltage waveform is

proportional to light• Scanner : 1-D image sensor• Camera : 2-D image sensor

CCD(Charge Coupled Device) CMOS(Complementary Metal-Oxide Semiconductor) Widely used in digital cameras and light sensing

instruments

• sampling and quantization step is required to use in the computer

54/74

Image capture

Page 28: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

55/74

Image capture

Two functions of CCD• converting photons to an electrical charge• moving this charge at the proper time

56/74

Image acquisition process

Creating a Digital ImageFor computer processing, an image intensity function f(x,y) must be digitized both spatially and in amplitude. And f(x,y) must be non-zero and finite.

0 < f(x,y) <

The function f(x,y) can be characterized by illumination and reflectance components.

f(x,y) = i(x,y) r(x,y)

Where

0 < i(x,y) < and 0 < r(x,y) < 1.

Page 29: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

57/74

Some typical ranges of i(x,y)• Clear day : 90,000 lm/m2

• Cloudy day : 10,000 lm/m2

• Full moon : 0.1 lm/m2

• Typical commercial office : 1000 lm/m2

Some typical ranges of r(x,y)• Black velvet : 0.01• Stainless steel : 0.65• Flat white wall paint : 0.80• Silver plated medal : 0.90• Snow : 0.93

Image acquisition process

lm(루멘) : 1 cd의 균일한 광도의 광원으로부터 단위입체각의 부분에방출되는 광속. 전 구면의 중심에 대한 입체각은 4p 이므로 1 cd의점광원에서 방출되는 전광속은 4 lm이다.

58/74

Sampling and Quantization

sampled image :digitizing the

coordinate values

quantized image :digitizing the

amplitude values

Page 30: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

59/74

Picture elements = pels = pixels

Digital Image

Digital image• sampled and quantized image

60/74

– spatial resolution: number of rows and columns (e.g. 256256)– gray-level resolution: 0 f(x,y) L, L = 2k-1(L = 1, 63, 255,

1023, etc.)– (x,y) : spatial coordinate, t : temporal coordinate

Digital Image Representation

Page 31: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

61/74

Digital Image Representation

Image representation• f(x,y) : 2-D still image• f(x,y,z) : 3-D still image• f(x,y,t) : 2-D moving image, video sequence• f(x,y,) : 2-D color image

The meaning of f(.)• Brightness of the subjects

- TV camera, scanner, etc.• Transmission factor of the subjects, especially bodies

- X-ray imaging, Ultrasonic imaging , etc.• Distance between the subjects and detector

- sonar imaging, radar, etc.• Temperature of the subjects

- infrared camera , etc.

62/74

Sampling effect

Digital Image Representation

Page 32: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

63/74

Digital Image Representation

Sampling theorem(표본화 정리)• If a function x(t) contains no frequencies higher than B hertz,

it is completely determined by giving its ordinates at a series of points spaced 1/(2B) seconds apart.

64/74

Spatial Aliasing

0

255

The spatial alising effect caused by undersampling

Original sampledUndersampled, Alising

Correctly sampledimage line-detailfrequency is captured

Original image line with brightnessdetails

Undersampled imageline-detail frequencyis aliased

Pixels are sampled at arate 2 times the detailfrequency

Pixels are sampled at arate less than half thedetail frequency

• It appears when the details in the image are sampled at a rate less than twice their spatial frequency

Page 33: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

65/74

Original image : Barbara

66/74

Filtered image : Barbara

Page 34: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

67/74

Size reduction only Filtering and size reduction

Size reduction comparison

68/74

Digital Image Representation

Quantizationeffect

Page 35: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

69/74

Quantizationeffect

false contourDigital Image Representation

70/74

Digital Image Storage

- The digitization process requires decisions about number of rows M, columns N and for the number, L, of discrete gray levels.L typically is an integer power of 2

L = 2k

- The number, b, of bits required to store a digitized image is

b = M x N x k

Page 36: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

71/74

Software

Simplest image format : PNM(Portable Anymap Format) file format• uncompress image format : easy to handle• PBM(portable bitmaps): binary image file format• PGM(portable graymap): gray-level image file format• PPM(portable pixelmap): color image file format• File format is defined in the File header

72/74

PNM file format

PNM header + image data PNM header

Magic Number What type of file and how data is storedImage Width Width of image in pixelsImage Height Height of image in pixelsMax Maximum gray scale/color channel value

• Header is written in ASCII form• Each field is separated by white space (blanks, tabs, line

feeds, or carriage returns)• Image data: ASCII or raw binary (called RAWBITS)• Max field is not used in PBM files• #: comment line, can’t be located in first line of file

Page 37: 1. Introduction Computer Engineering, Sejong University ...dasan.sejong.ac.kr/~dihan/ip/P01_chapter1_ENG_full.pdf · Simplest image format : PNM(Portable Anymap Format) file format

73/74

PNM file format

Magic number

Format ASCII RAWBITSPBM P1 P4PGM P2 P5PPM P3 P6

Image data format

74/74

PNM file format

PPM file exampleP3720 256255210 0 0214 0 0204 0 0209 0 0199 0 0204 0 0194 0 0199 0 0189 0 0194 0 0184 3 0189 8 0179 15 0184 19 0174 26 0179 31 0169 38 0174 43 0164 49 0169 54 0159 61 0164 66 0154 73 0158 77 5149 84 26153 89 31144 96 52148 101 57

720x256 imageImage

data in file

Magic number

Image size

Channel level

Image data