0
# Image Enhancement
1
2
Systematic image quality improvement through brightness, contrast, color saturation, and sharpness adjustments with intuitive enhancement classes.
3
4
## Capabilities
5
6
### Enhancement Classes
7
8
```python { .api }
9
class Color:
10
"""Color saturation enhancement."""
11
12
def __init__(self, image):
13
"""
14
Create color enhancer.
15
16
Parameters:
17
- image (Image): Image to enhance
18
"""
19
20
def enhance(self, factor):
21
"""
22
Enhance color saturation.
23
24
Parameters:
25
- factor (float): Enhancement factor (0.0=grayscale, 1.0=original, >1.0=enhanced)
26
27
Returns:
28
Image: Enhanced image
29
"""
30
31
class Contrast:
32
"""Contrast enhancement."""
33
34
def __init__(self, image):
35
"""Create contrast enhancer."""
36
37
def enhance(self, factor):
38
"""
39
Enhance contrast.
40
41
Parameters:
42
- factor (float): Enhancement factor (0.0=gray, 1.0=original, >1.0=enhanced)
43
44
Returns:
45
Image: Enhanced image
46
"""
47
48
class Brightness:
49
"""Brightness enhancement."""
50
51
def __init__(self, image):
52
"""Create brightness enhancer."""
53
54
def enhance(self, factor):
55
"""
56
Enhance brightness.
57
58
Parameters:
59
- factor (float): Enhancement factor (0.0=black, 1.0=original, >1.0=brighter)
60
61
Returns:
62
Image: Enhanced image
63
"""
64
65
class Sharpness:
66
"""Sharpness enhancement."""
67
68
def __init__(self, image):
69
"""Create sharpness enhancer."""
70
71
def enhance(self, factor):
72
"""
73
Enhance sharpness.
74
75
Parameters:
76
- factor (float): Enhancement factor (0.0=blurred, 1.0=original, >1.0=sharper)
77
78
Returns:
79
Image: Enhanced image
80
"""
81
```
82
83
## Usage Examples
84
85
```python
86
from PIL import Image, ImageEnhance
87
88
img = Image.open("photo.jpg")
89
90
# Enhance brightness
91
brightness = ImageEnhance.Brightness(img)
92
brighter = brightness.enhance(1.3)
93
94
# Enhance contrast
95
contrast = ImageEnhance.Contrast(brighter)
96
contrasted = contrast.enhance(1.2)
97
98
# Enhance color saturation
99
color = ImageEnhance.Color(contrasted)
100
colorized = color.enhance(1.1)
101
102
# Enhance sharpness
103
sharpness = ImageEnhance.Sharpness(colorized)
104
sharpened = sharpness.enhance(1.2)
105
106
sharpened.save("enhanced.jpg")
107
```