I2200: Digital Image processing Lecture 4: Spatial Domain Processing and Image Enhancement Prof. YingLi Tian Sept. 27, 2017 Department of Electrical Engineering The City College of New York The City University of New York (CUNY) Some materials from Dr. Lexing Xie, Alan Peters, and Dr. Shahram Ebadollahi 1
Announcement HW1 due yesterday! Adrian will present HW1 today. HW2 is out today, due: 10/10/2017 Mateusz will present HW2 on 10/11/2017. Midterm Exam: Oct. 18, 2017. Open notes No electronic device allowed except calculator 2
Outline: Intensity Transformation Intensity transformation functions (negative, log, gamma), intensity and bit-place slicing, contrast stretching Histograms: equalization, matching, local Processing Spatial Filtering Filtering basics, smoothing filters, sharpening filters, unsharp masking, Laplacian Combining spatial operations 3
Spatial Domain Processing Spatial domain processing: Methods based on direct manipulation on pixels in an image. Enhancement: the process of manipulating an image so that the result is more suitable than the original for a specific application. 4
Spatial Domain Processing 5
Intensity transformation 6
Intensity transformation example Color Space Transformation 7
Image negatives 8
Basic intensity transform functions monotonic, reversible compress or stretch certain range of gray-levels 9
Log transform The general form of the log transformation is s = c * log(1 + r) The log transformation maps a narrow range of low input grey level values into a wider range of output values The inverse log transformation performs the opposite transformation We usually set c to 1 Grey levels must be in the range [0.0, 1.0] 10
Log transform example Log functions are particularly useful when the input grey level values may have an extremely large range of values In the following example the Fourier transform of an image is put through a log transform to reveal more detail s = log(1 + r) 11
Power-law (Gamma) transformation 12
Gamma correction make linear input appear linear on displays method: calibration pattern + interactive adjustment 13
Effect of gamma on consumer photo 14
What gamma to use? 15
More intensity transform 16
Intensity slicing 17
Image bit-planes 18
Slicing bit-planes 19
Outline: Intensity Transformation Intensity transformation functions (negative, log, gamma), intensity and bit-place slicing, contrast stretching Histograms: equalization, matching, local Processing Spatial Filtering Filtering basics, smoothing filters, sharpening filters, unsharp masking, Laplacian Combining spatial operations 20
Gray-level image histogram 21
Interpretations of histogram 22
Contrast stretching 23
The Probability Density Function of an Image Let A 255 g 0 R rows by C h I g Note that since h I k k 1. A is the number of pixels in I. I k g 1 columns then is the number (the k th color band of image I ) with value g, A That is if R C. of I pixels in Then, 1 pi g 1 h 1 k I g k A is the graylevel probability density function of I. is pdf [lower case] This is the probability that an arbitrary pixel from I k has value g. k 24
The Probability Density Function of an Image p band (g+1) is the fraction of pixels in (a specific band of) an image that have intensity value g. p band (g+1) is the probability that a pixel randomly selected from the given band has intensity value g. Whereas the sum of the histogram h band (g+1) over all g from 1 to 256 is equal to the number of pixels in the image, the sum of p band (g+1) over all g is 1. p band is the normalized histogram of the band. 25
The Probability Density Function of an Image Let q = [q 1 q 2 q 3 ] = I(r,c) be the value of a randomly selected pixel from I. Let g be a specific graylevel. The probability that q k g is given by PDF [upper case] P I k g p 1 h 1 1 1 g g Ik 1 0 1 I k Ik 255 0 A 0 hi k 0 g h, where h Ik (γ +1) is the histogram of the kth band of I. This is the probability that any given pixel from I k has value less than or equal to g. 26
The Probability Density Function of an Image Let q = [q 1 q 2 q 3 ] = I(r,c) be the value of a randomly selected pixel from I. Let g be a specific graylevel. The probability that q k g is given by Also called CDF for Cumulative Distribution Function. P I k g p 1 h 1 1 1 g g Ik 1 0 1 I k Ik 255 0 A 0 hi k 0 g h, where h Ik (γ +1) is the histogram of the kth band of I. This is the probability that any given pixel from I k has value less than or equal to g. 27
The Probability Density Function of an Image P band (g+1) is the fraction of pixels in (a specific band of) an image that have intensity values less than or equal to g. P band (g+1) is the probability that a pixel randomly selected from the given band has an intensity value less than or equal to g. P band (g+1) is the cumulative (or running) sum of p band (g+1) from 0 through g inclusive. P band (1) = p band (1) and P band (256) = 1; P band (g+1) is nondecreasing. Note: the Probability Distribution Function (PDF, capital letters) and the Cumulative Distribution Function (CDF) are exactly the same things. Both PDF and CDF will refer to it. However, pdf (small letters) is the density function. 28
Histogram equalization Probability density function Cumulative distribution function 29
Histogram equalization 30
Implementing histogram equalization 31
Histogram equalization example 32
Histogram equalization example 33
Histogram equalization example 34
Contrast-stretching vs. histogram equalization 35
Histogram matching 36
Histogram matching example 37
Local histogram processing Image enhancement Problem: global spatial processing not always desirable Solution: apply point-operations to a pixel neighborhood with a sliding window 38
Outline: Intensity Transformation Intensity transformation functions (negative, log, gamma), intensity and bit-place slicing, contrast stretching Histograms: equalization, matching, local Processing Spatial Filtering Filtering basics, smoothing filters, sharpening filters, unsharp masking, Laplacian Combining spatial operations 39
Spatial filtering in image neighborhoods 40
Kernel operator / filter masks 41
Smoothing: image averaging 42
Spatial averaging can suppress noise IID noise: independently and identically distributed noise 43
Smoothing operator of different sizes 44
Directional smoothing 45
Non-linear smoothing operator 46
Median filter example 47
Image derivative and sharpening 48
Edge and the first derivative Edge: pixel locations of abrupt luminance change Spatial luminance gradient vector a vector consists of partial derivatives along two orthogonal directions gradient gives the direction with highest rate of luminance changes Representing edge: edge intensity + directions Detection Methods prepare edge examples (templates) of different intensities and directions, then find the best match measure transitions along 2 orthogonal directions 49
Edge detection operators 50
Edge detection examples 51
Second derivative in 2D 52
Laplacian of roman ruins http://flickr.com/photos/starfish235/388557119/ 53
Unsharp masking 54
High-boost filtering 55
Unsharp mask example 56
Unsharp mask example 57
Unsharp mask example http://flickr.com/photos/dpgnashua/2274968238/ 58
Unsharp mask example 59
Combining spatial operations 60
Combining spatial operations 61
How to avoid a boring presentation?
Presentation Skills -- 1 Presentations are one of the first managerial skills which a engineer must acquire Formulate your Objectives Identify the Audience Structure Beginning Ending Make Good Slides 63
Presentation Skills -- 2 Be confident Keep eye contacts Appropriate posture (body language) Make sure all the audience can hear you Speak slowly and clearly Speak loudly Pause Know all the technical terms you may be using. Also avoid using abbreviations or jargon terms that the audience will not understand. Smile Practice 64
Handling Difficult Questions Make sure you understand the question. If you are not able to answer a question then it is fine to say so! Ask if anyone else in the group knows the answer. Let the participant know that you will get back to them at a later date with the answer - and make sure you get back to them! 65
Dealing with questions It is OK to say I don t know for the questions you don t know the answer!!! Some phrases which can be useful when you want to avoid questions: That s not really my field, but I can put you in touch with someone who is an expert in the field. Well, I think that goes beyond the scope of today s presentation. I m afraid we ve run out of time. I haven't got the precise information with me today. That's not really for me to say. This is not really the place to discuss that matter. Perhaps that's a question for another meeting.
Body Language Presentation Video 67
Making PowerPoint Slides Avoiding the Pitfalls of Bad Slides http://www.iasted.org/conferences/f ormatting/presentations-tips.ppt
Tips to be Covered Outlines Slide Structure Fonts Color Background Graphs Spelling and Grammar Conclusions
Outline Make your 1 st or 2 nd slide an outline of your presentation Ex: previous slide Follow the order of your outline for the rest of the presentation Only place main points on the outline slide Ex: Use the titles of each slide as main points
Slide Structure Good Use 1-2 slides per minute of your presentation Write in point form, not complete sentences Include 4-5 points per slide Avoid wordiness: use key words and phrases only
Slide Structure - Bad This page contains too many words for a presentation slide. It is not written in point form, making it difficult both for your audience to read and for you to present each point. Although there are exactly the same number of points on this slide as the previous slide, it looks much more complicated. In short, your audience will spend too much time trying to read this paragraph instead of listening to you.
Slide Structure Good Show one point at a time: Will help audience concentrate on what you are saying Will prevent audience from reading ahead Will help you keep your presentation focused
Slide Structure - Bad Do not use distracting animation Do not go overboard with the animation Be consistent with the animation that you use
Fonts - Good Use at least an 18-point font Use different size fonts for main points and secondary points this font is 24-point, the main point font is 28-point, and the title font is 36-point Use a standard font like Times New Roman or Arial
Fonts - Bad If you use a small font, your audience won t be able to read what you have written CAPITALIZE ONLY WHEN NECESSARY. IT IS DIFFICULT TO READ Don t use a complicated font
Colour - Good Use a color of font that contrasts sharply with the background Ex: blue font on white background Use color to reinforce the logic of your structure Ex: light blue title and dark blue text Use color to emphasize a point But only use this occasionally
Colour - Bad Using a font colour that does not contrast with the background colour is hard to read Using colour for decoration is distracting and annoying. Using a different colour for each point is unnecessary Using a different colour for secondary points is also unnecessary Trying to be creative can also be bad
Background - Good Use backgrounds such as this one that are attractive but simple Use backgrounds which are light Use the same background consistently throughout your presentation
Background Bad Avoid backgrounds that are distracting or difficult to read from Always be consistent with the background that you use
Graphs - Good Use graphs rather than just charts and words Data in graphs is easier to comprehend & retain than is raw data Trends are easier to visualize in graph form Always title your graphs
Graphs - Bad January February March April Blue Balls 20.4 27.4 90 20.4 Red Balls 30.6 38.6 34.6 31.6
Graphs - Good Items Sold in First Quarter of 2002 100 90 80 70 60 50 40 30 20 10 0 January February March April Blue Balls Red Balls
Graphs - Bad 100 90 90 80 70 60 50 Blue Balls Red Balls 40 30 30.6 27.4 38.6 34.6 31.6 20 20.4 20.4 10 0 January February March April
Graphs - Bad Minor gridlines are unnecessary Font is too small Colours are illogical Title is missing Shading is distracting
Spelling and Grammar Proof your slides for: speling mistakes the use of of repeated words grammatical errors you might have make If English is not your first language, please have someone else check your presentation!
Conclusion Use an effective and strong closing Your audience is likely to remember your last words Use a conclusion slide to: Summarize the main points of your presentation Suggest future avenues of research
Announcement HW1 due yesterday! Adrian will present HW1 today. HW2 is out today, due: 10/10/2017 Mateusz will present HW2 on 10/11/2017. Midterm Exam: Oct. 18, 2017. Open notes No electronic device allowed except calculator 88
HW 1 PRESENTATION 89