Lec08, Image II (Enhancement), v1.02.pdf

Course Presentation
Multimedia Systems
Image II
(Image Enhancement)
Mahdi Amiri
March 2011
Sharif University of Technology
Image Enhancement
Have seen so far
Gamma Correction
Page 1
Histogram Equalization
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Image Enhancement
Definition
Image enhancement deals with the improvement of
visual appearance of the scene, to improve the detectability
of objects to be used by either a machine vision system or a
human observer.
Sources of image deterioration
Noise
Low Resolution
Quantization levels
Source of noise
Electronic signal fluctuations in detector ( CCD chip )
Page 2
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Image Enhancement
Image Noise
The random variation of brightness or color information in images
An undesirable by-product of image capture
‘grainy’ image, noise from a digital camera
Page 3
Image with salt and pepper noise
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Image Filters
Gaussian smoothing
Noise fluctuations are rapid, ie, high frequency.
Gaussian filters are a class of smoothing filters where the kernel
values have a 2D Gaussian shape.
Sweep The Image
1D Gaussian Filter
1/16
1
4
6
4
1
4
16
24
16
4
6
24
36
24
6
1
2
1
2
4
2
4
16
24
16
4
1
2
1
1
4
6
4
1
3x3 Kernel
Page 4
1/256
2D Gaussian Filter
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
5x5 Kernel
Image Filters
Mean Filter
To replace each pixel value in an image with the mean (`average')
value of its neighbors
Kernel: represents the shape and size of the neighborhood
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
Typ. Mean Filter
Kernel
A halftone print
Page 5
Mean filtered
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Image Filters
Median Filter
Replacing each entry with the median of neighboring entries
Nonlinear digital filtering technique
Used to remove noise
Pro: under certain conditions, it preserves edges while removing
noise
Input: x = [2 80 6 3], Window size: 3
1D Example:
The median filtered output signal y:
y[1] = Median[2 2 80] = 2 (Left padding with 2)
y[2] = Median[2 80 6] = Median[2 6 80] = 6
y[3] = Median[80 6 3] = Median[3 6 80] = 6
y[4] = Median[6 3 3] = Median[3 3 6] = 3 (Right padding with 3)
i.e. y = [2 6 6 3].
Page 6
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Median Filter
2D Median Filter Example
Input Image
Page 7
Mean Filtered Image
Median Filterd Image
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Box Filtering
Original unfiltered image
0
0
0
0
1
0
0
0
0
Kernel
Page 8
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Box Filtering
See
http://tech-algorithm.com/articles/boxfilteringinteractive-applet/
Example Java Code
public int[] BoxFiltering(
int[] pixels,int width, int height, float[] kernel) {
int[] temp = new int[width*height] ;
float denominator = 0.0f ;
float red, green, blue ;
int ired, igreen, iblue, indexOffset, rgb ;
int[] indices = {
-(width + 1), -width, -(width - 1),
-1,
0,
+1
, width – 1, width, width + 1
} ;
for (int i=0;i<kernel.length;i++)
denominator += kernel[i] ;
if (denominator==0.0f) denominator = 1.0f ;
for (int i=1;i<height-1;i++) {
for (int j=1;j<width-1;j++) {
[Include Part A]
}
}
return temp ; }
[Part A]
red = green = blue = 0.0f ;
indexOffset = (i*width)+j ;
for (int k=0;k<kernel.length;k++) {
rgb = pixels[indexOffset+indices[k]] ;
red += ((rgb & 0xff0000)>>16)*kernel[k] ;
green += ((rgb & 0xff00)>>8)*kernel[k] ;
blue += (rgb & 0xff)*kernel[k] ;
}
ired = (int)(red / denominator) ;
igreen = (int)(green / denominator) ;
iblue = (int)(blue / denominator) ;
if (ired>0xff) ired = 0xff ;
else if (ired<0) ired = 0 ;
if (igreen>0xff) igreen = 0xff ;
else if (igreen<0) igreen = 0 ;
if (iblue>0xff) iblue = 0xff ;
else if (iblue<0) iblue = 0 ;
temp[indexOffset] = 0xff000000 | ((ired<<16) &
0xff0000) |
((igreen<<8) & 0xff00) | (iblue & 0xff) ;
The parameter pixels is an array containing a total of width*height pixel information. The parameter kernel is an array with a fixed
length of nine. This is because the implementation assumes a window of size 3x3. The function also assume each pixel is in the
form ARGB (alpha, red, green, blue), where blue is the least significant byte. Alpha is the transparency information and should just
be left untouched. The array indices is a simple optimization table used to find neighboring pixels. The denominator is the sum of
parameter kernel, it will be the denominator when calculating average.
Page 9
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Box Filtering
Smoothing (~ Mean Filter)
Kernel
Kernel
(with denominator) (without denominator)
0
0
0
0
1
0
0
0
0
Page 10
1/10 1/10 1/10
1
1
1
1/10 2/10 1/10
1
2
1
1/10 1/10 1/10
1
1
1
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Box Filtering
Sharpening (Edge Enhancement)
Kernel
(without denominator)
0
0
0
0
1
0
0
0
0
Page 11
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
-1
-1
-1
-1
9
-1
-1
-1
-1
Box Filtering
Raised
Kernel
(without denominator)
0
0
0
0
1
0
0
0
0
Page 12
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
0
0
-2
0
2
0
1
0
0
Box Filtering
Motion Blur
Kernel
(without denominator)
0
0
0
0
1
0
0
0
0
Page 13
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
0
0
1
0
0
0
1
0
0
Box Filtering
Edge Detection
Kernel
(without denominator)
0
0
0
0
1
0
0
0
0
Page 14
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
-1
-1
-1
-1
8
-1
-1
-1
-1
Image Enhancement
Despeckle
Speckle detection and deletion
Allows the removal of speckle in scanned or faxed
images. The speckle is the presence of black points of noise
in images acquired by a scanner or received by fax.
Page 15
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Color Adjustments
Example of color correction in photoshop
Page 16
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Image Enhancement
Real-time Filtering
Application
HD video conferencing, multi-focus imaging
Page 17
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Image Editors
Paint.NET
http://www.getpaint.net/
Paint.NET is a proprietary freeware raster graphics editor program
for Microsoft Windows, developed on the .NET Framework.
Page 18
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Image Editors
http://www.gimp.org/
GIMP
GIMP (short for the GNU Image Manipulation Program) is a free software
raster graphics editor. (Microsoft's Windows, Apple's Mac OS X, GNU/Linux)
GIMP 2.2.8 running under X11 on Mac OS X
GIMP 2.6 running on Ubuntu
See: http://en.wikipedia.org/wiki/Comparison_of_raster_graphics_editors
Page 19
Multimedia Systems, Spring 2011, Mahdi Amiri, Image II
Multimedia Systems
Image II
Thank You
Next Session: Image III
FIND OUT MORE AT...
1. http://ce.sharif.edu/~m_amiri/
2. http://www.dml.ir/
Page 20
Multimedia Systems, Spring 2011, Mahdi Amiri, Image I