You are on page 1of 9

Graphics Processing Systems 2015

Project
Image Effects

Author:
Ungureanu Estera-Bianca
2nd year MIT, 2016

Page 1 of 9

1) YUV Image Format


The Y'UV model defines a color space in terms of one luma (Y') and two chrominance (UV)
components.
YUV has basically three components:
the luminance or green channel (Y),
the colour value of the luminance deducted from the colour red (R-Y),
the colour value of the luminance deducted from the colour blue (B-Y).
When digitised, these three parameters of the component video signal are assigned a numeric value.
Subsampling Ratio Example 4:2:0 (fig.1)
4:
Luma horizontal sampling reference
2:
Cb and Cr Horizontal factor
0:
Cb and Cr are sub-sampled 2:1 vertically

fig.1
For the Project, the channels Y,U,V have ranges from 0 to 255 in unsigned char form.
All the input images are in format YUV 420p with size (width x heigh)t = 640x480 (VGA).

2) Image Effects
a) Sharpen : Image sharpening falls into a category of image processing called spacial filtering. The
Laplacian operator is an example of a second order or second derivative method of enhancement. As a
result, the Laplacian operator store fine detail of an image which has been smoothed to remove noise.
It is a matrix and looks like this fig.2. To complete the image sharpening the filtered Laplacian image
is subtracted back to the original image, and scale the data into the range 0 to 255.
fig.2

1 1 1
1 -8 1
1 1 1

b) Emboss : An emboss filter gives a 3D shadow effect to the image, the result is very useful for a
bumpmap of the image. It can be achieved by taking a pixel on one side of the center, and subtracting
one of the other side from it. Pixels can get either a positive or a negative result. To use the negative
pixels as shadow and positive ones as light, for a bumpmap, a bias of 128 is added to the image. Now,
most parts of the image will be gray, and the sides will be either dark gray/black or bright gray/white.

fig.3
Page 2 of 9

c) Blur

fig.4
d) Motion Blur : Motion blur is achieved by blurring in only 1 direction. It's as if the camera is
moving from the top left to the bottom right.

fig.5
e) Edge Detect :

fig.6
f) Grayscale : Y channel remain the same, U and V channels are are setted to middle value.
(256/2 = 128)
g) Luminance enhance (histogram equalization)
Histogram equalization is performed in the following way:
The histogram of the input image is calculated;
Cumulative distribution of the histogram is calculated;
Use the cumulative distribution to construct a look-up table that maps each gray value to the
equalized one and
Update the image using the look-up table constructed in the last step.

3) Tools:

Converting an image to yuv:


Command ffmpeg -i Stripes.jpg -pix_fmt yuv420p -s 640x480 Stripes_P420_640x480.yuv
http://adaptivesamples.com/how-to-install-ffmpeg-on-windows/
PYUV Player
http://dsplab.diei.unipg.it/~baruffa/dvbt/player.php

Page 3 of 9

4) Appendix
An example small grayscale image (10x10):
34
50
93
32
10
192
239
230
227
215

22
150
0
19
90
70
202
174
86
165

77
77
77
44
48
27
196
14
195
237

48
158
219
30
73
88
205
22
6
110

237
233
43
36
63
20
50
127
53
125

205
251
56
94
148
230
123
100
168
191

29
112
42
151
159
53
192
189
46
191

212
165
113
101
183
34
88
186
166
94

107
47
140
28
99
38
41
214
36
123

41
229
94
84
22
106
37
187
249
8

An example convolution filter for line detection:


-1
-1
-1

-1
8
-1

-1
-1
-1

The row=2, column=2 pixel and its neighborhood from the image above: The row=2, column=2
pixel and its neighborhood from the image above:
34
50
93

22
150
0

77
77
77

To apply the convolution filter multiply the filter values with the image data block. Work with each pixel
and its 3x3 neighborhood:
-1*34
-1*50
-1*93

-1*22
8*150
-1*0

-1*77
-1*77
-1*77

Then sum all the values:


(-34)+(-22)+(-77)+
(-50)+(1200)+(-77)+
(-93)+(0)+(-77) = 770
If the new pixel value is > 255 set it to 255
If the new pixel value is < 0 set it to 0
Page 4 of 9

The new pixel value is 255.


Store that in a new image:

34
50
93

22
255
0

77
77
77

Continue with all other 3x3 blocks in the image using original values. For example the next image block
is:
22
150
0

77
77
77

48
158
219

The 3x3 "window" is shifted to the right by one and that the new pixel value is NOT used but stored as a
second new image.
Most of the image is processed in this manner. Image borders create problems and are ignored.
Many filters can easily be defined for other purposes.

5) Results
YUV Channels

Page 5 of 9

Sharpen

Emboss
Page 6 of 9

Blur

Motion Blur

Page 7 of 9

Edge Detect

Gray

Page 8 of 9

Luminance enhancement

Page 9 of 9

You might also like