-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexample.py
More file actions
37 lines (25 loc) · 1.11 KB
/
example.py
File metadata and controls
37 lines (25 loc) · 1.11 KB
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
35
36
37
#!/usr/bin/env python3
"""
@license: Apache License Version 2.0
@author: Stefano Di Martino
Exact histogram matching
"""
import imageio
from histogram_matching import ExactHistogramMatcher
def histogram_matching_rgb():
target_img = imageio.imread('images/RGB/Luna_medium.jpg')
reference_img = imageio.imread('images/RGB/Luna_White_Balance_medium.jpg')
reference_histogram = ExactHistogramMatcher.get_histogram(reference_img)
new_target_img = ExactHistogramMatcher.match_image_to_histogram(target_img, reference_histogram)
imageio.imsave('rgb_out.png', new_target_img)
def histogram_matching_grey_values():
target_img = imageio.imread('images/GreyValue/Luna_medium.jpg')
reference_img = imageio.imread('images/GreyValue/Luna_White_Balance_medium.jpg')
reference_histogram = ExactHistogramMatcher.get_histogram(reference_img)
new_target_img = ExactHistogramMatcher.match_image_to_histogram(target_img, reference_histogram)
imageio.imsave('grey_out.png', new_target_img)
def main():
histogram_matching_rgb()
histogram_matching_grey_values()
if __name__ == "__main__":
main()