-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbrightness.py
More file actions
34 lines (25 loc) · 940 Bytes
/
Copy pathbrightness.py
File metadata and controls
34 lines (25 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from PIL import Image, ImageEnhance
from matplotlib import pyplot as plt
'''
Brightness: This class can be used to control the
brightness of an image. An enhancement
factor of 0.0 gives a black image.
A factor of 1.0 gives the original image.
'''
img = Image.open("sim1.jpg")
enhancer = ImageEnhance.Brightness(img)
#An enhancement factor of 0.0 gives a black image. A factor of 1.0 gives the original image.
factor = 1
img1 = enhancer.enhance(factor)
#An enhancement factor of 0.0 gives a black image. A factor of 1.0 gives the original image.
factor = 3.5
img2 = enhancer.enhance(factor)
# img --> <class 'PIL.JpegImagePlugin.JpegImageFile'>
# img1 e img2 --> <class 'PIL.Image.Image'>
plt.figure(num='Fallimento BRIGHTNESS')
plt.subplot(121),plt.imshow(img1),plt.title('Originale')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(img2),plt.title('Luminosità Aumentata')
plt.xticks([]), plt.yticks([])
plt.show()
#ok