56
תתתתת תתתתתת

עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Embed Size (px)

Citation preview

Page 1: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

תמונות עיבוד

Page 2: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Optical character recognition (OCR)

Digit recognition, AT&T labshttp://www.research.att.com/~yann/

Technology to convert scanned docs to text• If you have a scanner, it probably came with OCR software

License plate readershttp://en.wikipedia.org/wiki/Automatic_number_plate_recognition

Page 3: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Face detection

• Many new digital cameras now detect faces– Canon, Sony, Fuji, …

Page 4: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Login without a password…

Fingerprint scanners on many new laptops,

other devices

Face recognition systems now beginning to appear more widely

http://www.sensiblevision.com/

Page 5: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

The Matrix movies, ESC Entertainment, XYZRGB, NRC

Special effects: shape capture

Page 6: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Smart cars

• Mobileye [wiki article]– Vision systems currently in high-end BMW, GM,

Volvo models – By 2010: 70% of car manufacturers.

Slide content courtesy of Amnon Shashua

Page 7: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Google cars

http://www.nytimes.com/2010/10/10/science/10google.html?ref=artificialintelligence

Page 8: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Computer vision vs human vision

What we see What a computer sees

Page 9: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

2004נמרוד פלג

סמוכים ותחומים תמונה עיבודתמונות “• ” עיבוד ” הקלט” בהן משימות ב דן

. תמונות הינם והפלטממוחשבת “• , ראיה אינו”: והפלט תמונה הקלט

עליה ) מידע אלא (.Computer Visionתמונהממוחשבת “• כלשהו”: גרפיקה מידע הינו הקלט

(. תמונה הינו (.Computer Graphicsוהפלט- לדוגמא• גופים: של מימדי התלת המיפוי מציאת

ריאליסטית, תמונה בנית לעומת בתמונה - במרחב מימדיים תלת גופים על ממידע

(Rendering.)

Page 10: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

2004נמרוד פלג

לתמונה אופיני מסלולאופטיקה

אלקטרו-אופטיקה

עיבוד האות

עיבוד התמונה

ראייה

עדשת מצלמה •

CCD גלאי •

תיקון תחום דינמי, •כימוי …

דחיסה ושיפור•

הבנת התמונה•

עדשת העין )מיקוד) •

חישני מע’ הראייה•(Cones, Rods)

תיקון תחום דינמי, •כימוי ועוד במע’

הראיה

דחיסה ושיפור, •במסלול עין-מוח

ובמוח הראייה.

הבנת התמונה:•זיהוי, תנועה…

Page 11: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

2004נמרוד פלג

תמונה בעיבוד שונים תחומים” Enhancement )שיפור• שנוצרו(: “ קלקולים סילוק

בדגימה..Restoration )שחזור• ידוע(: שטיבם קלקולים סילוק’ Analysis )ניתוח• ” מע(: לצורך כ בדר מרכיבים זיהוי

אוטומטיות.” Compression )דחיסה• סילוק(: י ע חסכוני ייצוג

. חיוני לא מידע- Reconstruction )בנייה• מידע(: סמך על הרכבה

)” “ ” חתכים ) י ע הדמיה חלקי

Page 12: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Continuous image

– Function from to

– How images are in the real world

– “Continuous” refers to the domain, not the values (discontinuities could still exist)

• Discrete Images

– How computers think

Image Processing 12

Discrete Images vs. Continuous Images

Continuous image

𝑘

𝑛

Page 13: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Image Processing 13

• The stages are– Image acquisition – how we obtain images

in the first place– Preprocessing – any effects applied before

mapping (e.g. crop, mask, filter)– Mapping – catch-all stage involving image

transformations or image composition– Postprocessing – any effects applied after

mapping (e.g. texturizing, color remapping)

– Output – printing or displaying on a screen

• Stages are sometimes skipped• The middle stages are often interlaced

The Five Stages of Image Processing

Page 14: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Image Processing 14

• Image Synthesis– Images created by a

computer– Painted in 2D

• Corel Painter (website)• Photoshop (website)

– Rendered from 3D geometry• Pixar’s RenderMan (website)• Autodesk’s Maya (website)

– Procedurally textured• Generated images intended

to mimic their natural counterparts

• E.g. procedural wood grain

Image Capture

Images from the “real world”Information must be digitized from an analog signalCommon capture methods:

Digital cameraSatellite dataDrum scannerFlatbed photo scannerFrames from video

Stage 1: Image Acquisition

Page 15: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: תמונה ספרתית 15

ספרתית תמונה

Gonzalez & Woods

Page 16: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: תמונה ספרתית 16

ספרתית תמונה

• Transforming the 3D world into 2D image Perspective projection

• Sampling the image plane Finite number of pixels

• Quantizing the color/gray level Finite number of colors

Page 17: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

פרספקטיבה הטלת

עיבוד סיפרתי של תמונות: תמונה ספרתית 17

- - ממד לדו ממד מתלת העתקה

(x,y,z)Y

XZ

x

f

Z

y

YZ

fy

XZ

fx

(x,y)

(X,Y,Z)

Page 18: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

2004נמרוד פלג

ורציפותן האפור רמותהינו, “• מצלמים אותו האובייקט הן רציף”במקור

בצבעו”( )“מרחבבשטחו )” אך”(, בהיקותוהן , מעשיים משיקולים חייבים למחשב במעבר

פיקסלים ) לדגום מסוימות בנקודות התמונה אתבדידות( ) אפור רמות מסוימים ובצבעים ).בדידים

• ) של ) מטריצה או מערך מיצגות מתקבל נקודות

Discreteהערה: בדיד = דיסקרטי ,

Page 19: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

2004נמרוד פלג

צבע בתמונת ? ומה

נקודה • כל מורכבת צבע ( pixel )בתמונת : יסוד צבעי וכחול ירוק, אדוםמשלשה

” RGBמסומן) י(, ע פיקסל כל נתאר ולכן: פונקציות rשלש x y g x y b x y( , ), ( , ), ( , )

Page 20: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

וכימוי ) (Sampling & Quantificationדגימה

עיבוד סיפרתי של תמונות: תמונה ספרתית 20

Gonzalez & Woods

Page 21: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: תמונה ספרתית 21

תמונה ( דגימת הפיקסלים ) מספרSampling

4X4

16X16

8X8

32X32

64X64

128X128

Page 22: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: תמונה ספרתית 22

(Quantization) – כימוי( לפיקסל האפשריות (מרחב

256 Levels 16 Levels 4 Levels 2 Levels

Page 23: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: תמונה ספרתית 23

ספרתית תמונה ייצוג

• מספרים של ) מטריצה , צבעי אפור (LUT דרגות• שלשות של (RGB) מטריצה

122 103 3 17 5 100

200 87 0 117 205 128

205 87 0 118 206 2

255 50 128 119 210 254

Gonzalez & Woods

Page 24: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

תמונה של זיכרון נפח

עיבוד סיפרתי של תמונות: תמונה ספרתית 24

N

M

k2 אפור דרגות מספרMN פיקסלים מספרkNM התמונה נפח

Page 25: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: תמונה ספרתית 25

היסטוגרמה Frequency counting of gray levels

0

2

4

6

8

10

12

14

16

18

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Freq

uen

cy

Gray-Level

In the limit of continuous intensities: a continuous probability distribution p(g)

Page 26: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: תמונה ספרתית 26

דוגמא- היסטוגרמה

Page 27: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Each source image is adjusted to fit a given tone, size, shape, etc., to match a desired quality or to match other images

• Can make a set of dissimilar images appear similar (if they are to be composited later), or make similar parts of an image appear dissimilar (such as contrast enhancement)

Image Processing 27

Stage 2: Preprocessing

Original

Adjusted grayscale curve

Page 28: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Preprocessing techniques include:– Adjusting color or grayscale curve

– Cropping

– Masking (cutting out part of an image)

– Blurring and sharpening

– Edge detection/enhancement

– Filtering and antialiasing

– Scaling up (super sampling) or scaling down (sub sampling)

Image Processing 28

Stage 2: Preprocessing (continued)

Page 29: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

2004נמרוד פלג

תמונה שיפורהתמונה צילום או דגימת במהלך המתקבלים אופיניים , קלקולים

להבחין מפריעיםמטשטשים, בפרטים

האובייקט אתוכדומה.

תמונת מקור: תצ”א(Aerial)

Page 30: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

2004נמרוד פלג

נמוכה (Low Contrast) ניגודיות

Page 31: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

2004נמרוד פלג

(Blur) טשטוש

Page 32: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

2004נמרוד פלג

נוספים קלקולים

נכון • לא (.De-Focus )מיקוד•. הגוף או המצלמה של רעידה או תזוזה•) טורבולנציה ) אויר של תרמיות תנועות

• ” מתאים עיבוד י ע מהבעיות חלק לתקן ניתן: לזכור חייבים אך

לא ניתן להוסיף מידע שלא היה קיים בתמונה !המקורית

)או בתמונות המקוריות(

Page 33: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Notes:

– Blurring, sharpening, and edge detection can also be postprocessing techniques

– Some preprocessing algorithms are not followed by mapping, others that involve resampling the image may be interlaced with mapping: filtering is done this way

Image Processing 33

Stage 2: Preprocessing (continued)

Page 34: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Image Processing 34

• Mapping is a catch-all stage where several images are combined, or geometric transformations are applied

• Transformations include:– Rotating– Scaling– Warping

• Compositing:– Basic image overlay– Smooth blending with alpha channels– Poisson image blending

• Seamlessly transfers “details” (like edges) from part of one image to another

Stage 3: Mapping

Poisson Image Blending

Image Warping

Image credit: © Evan Wallace 2010

Page 35: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Objects in a scene are a collection of points…

• These objects have location, orientation, size• Corresponds to transformations, Translation (), Rotation

(), and Scaling ()

35/45

How do we use Geometric Transformations? (1/2)

Page 36: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

•3D Coordinate geometry•Vectors in 2 space and 3 space•Dot product and cross product – definitions and uses•Vector and matrix notation and algebra•Identity Matrix•Multiplicative associativity

•E.g. A(BC) = (AB)C

•Matrix transpose and inverse – definition, use, and calculation•Homogeneous coordinates ()

You will need to understand these concepts!

Linear Algebra Help Session Notes: http://cs.brown.edu/courses/cs123/resources/Linear_Algebra.pdf 36/45

Some Linear Algebra Concepts...

Page 37: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

– We represent vectors as bold-italic letters () and scalars as just italicized letters (c)

– Any vector in plane can be defined as addition of two non-collinear basis vectors in the plane• Recall that a basis is a set of vectors with the following

two properties:

• The vectors are linearly independent

• Any vector in the vector space can be generated by a linear combination of the basis vectors

– Scalar constants can be used to adjust magnitude and direction of resultant vector

37/45

Linear Transformations (1/3)

a b = a + b

Page 38: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

38/45

Linear Transformations as Matrices (1/2)

Page 39: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• A transformation of an arbitrary column vector has form:

=

• Let’s substitute for = – transformation applied to is 1st column of

• Now substitute for = – transformation applied to is 2nd column of

39/45

Linear Transformations as Matrices (2/2)

Page 40: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Scale by 3, by 2 (Sx = 3, Sy = 2)– = (original vertex); =

(new vertex)

• Derive by determining how and should be transformed

– = * = (Scale in X by ) , the first column of

– = * = (Scale in Y by), the second column of

• Thus we obtain : 40/45

Scaling in 2D (1/2)Side effect: House shifts position relative to origin

2

6

2

9

1

2

1

3

Andy van Dam
where what?!? i assume it is showing the matrix for S. i made room for it but broke the animationthe animation of the fig should start after the second subbullet of the first bullet
Page 41: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• is a diagonal matrix - can confirm our derivation by simply looking at properties of diagonal matrices:

• = – where is some diagonal matrix

• entry of = ( entry along diagonal of entry of )

• multiplies each coordinate of a by scaling factors () specified by the entries along the diagonal, as expected

– = , =

41/45

Scaling in 2D (2/2) Other properties of scaling:

does not preserve lengths in objects does not preserve angles between parts

of objects (except when scaling is uniform,)

if not at origin, translates house relative to origin– often not desired…

Page 42: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Rotate by about origin • where

– = )original vertex(

– = )new vertex(

– Derive by determining how and should be transformed

• = , first column of • = , second column of

– Thus we obtain :

42/45

Rotation in 2D (1/2)

Page 43: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Let’s try matrix-vector multiplication • = = ’

• Other properties of rotation:– preserves lengths in objects, and angles between parts of objects– rotation is rigid-body– for objects not at the origin, again a translation may be unwanted (i.e., this

rotates about origin, not about house’s center of rotation)

43/45

Rotation in 2D (2/2)

Page 44: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Translation not a linear transformation (not centered about origin)

• Can’t be represented as a 2x2 invertible matrix …

• Question: Is there another solution?

• Answer: Yes, , where • Addition for

translation – this is inconsistent

44/45

What about translation? If we could treat all transformations in a

consistent manner, i.e., with matrix representation, then could combine transformations by composing their matrices

Let’s try using a Matrix again How? Homogeneous Coordinates: add

an additional dimension, the w-axis, and an extra coordinate, the w-component thus 2D -> 3D (effectively the hyperspace

for embedding 2D space)

Page 45: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Translation uses a 3x3 Matrix, but Scaling and Rotation are 2x2 Matrices• Let’s homogenize! Doesn’t affect linearity property of scaling and rotation• Our new transformation matrices look like this…

• Note: These 3 transformations are called affine transformations

45/45

Transformations Homogenized

Transformation Matrix

Scaling

Rotation

Translation

Page 46: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

• Scaling: Scale by 15 in the direction, 17 in the

• Rotation: Rotate by 1

• Translation: Translate by -16 in the , +18 in the

46/45

Examples

Page 47: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Aging

Image Processing 47

• Creates global effects across an entire image or selected area

• Art effects– Posterizing– Faked “aging” of an image– Faked “out-of-focus”– “Impressionist” pixel remapping– Texturizing

• Technical effects– Color remapping for contrast enhancement – Color to B&W conversion – Color separation for printing (RGB to CMYK)– Scan retouching and color/contrast balancing

• Edge Detection

Stage 4: Postprocessing

Posterizing

Impressionist

Page 48: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: קצוות תמונה 48

קצוות תמונהEdge Detection

Page 49: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: קצוות תמונה 49

תמונה קצוות

קצוות שלתמונה סינטטית

קצוות מאפייניאובייקטים

שאינם קצוות מאפייניםאובייקטים

Page 50: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

בנגזרות שימוש

עיבוד סיפרתי של תמונות: קצוות תמונה 50

f(x)

f’(x)

f’’(x)

f(x)-f’’(x)

נקודת חציית האפס

גובה הנגזרת מאפייןאת שיפוע המדרגה

Page 51: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: קצוות תמונה 51

ראשונות נגזרות

הגרדיאנט :אופרטור

y

f

x

ff ,

הגרדיאנט :גודל22

y

f

x

ff

הגרדיאנט :כיוון

xf

yf1tan

Page 52: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: קצוות תמונה 52

ראשונות נגזרות

Gonzalez & Woods

Page 53: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: קצוות תמונה 53

רועשת תמונה של נגזרות

Gonzalez & Woods

Page 54: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: קצוות תמונה 54

רועשת תמונה של ראשונה נגזרת

Page 55: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

עיבוד סיפרתי של תמונות: קצוות תמונה 55

רועשת תמונה של ראשונה נגזרת

הגזירה: לפני החלקה לבצע פתרון

Gonzalez & Woods

Page 56: עיבוד תמונות. Optical character recognition (OCR) Digit recognition, AT&T labs yannyann/ Technology

Image Processing 56

• Choice of display/archive method may affect earlier processing stages– Color printing accentuates certain

colors more than others – Colors on the monitor have

different gamuts and HSV values than the colors printed out

• Need a mapping

– HSV = hue, saturation, value, a cylindrical coordinate system for the RGB color model

– Gamut = set of colors that can be represented by output device/printer

Display Technologies

Monitor (CRT → LCD/LED/OLED/Plasma panel)Color printerFilm/DVD Disk fileTexture map for 3D renderer

Stage 5: Output (Archive/Display)