-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistogramProbability.py
More file actions
37 lines (34 loc) · 1.16 KB
/
Copy pathhistogramProbability.py
File metadata and controls
37 lines (34 loc) · 1.16 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
import cv2
import os
import numpy
def equalizeHistogram (image, factor):
image2 = cv2.cvtColor(image, cv2.COLOR_BGR2HLS)
height, width, channels = image2.shape
array = []
for i in range(0, 256):
array.append(0)
for x in range(0, height):
for y in range(0, width):
index = image2[x,y,1]
array[index] += 1
minIndex = 0
maxIndex = 255
if index - factor > 0:
minIndex = index - factor
if index + factor < 255:
maxIndex = index + factor
rangeForMin = array[(minIndex):(maxIndex+1)]
min = numpy.argmin(rangeForMin) + (minIndex)
image2[x,y,1] = min
image2 = cv2.cvtColor(image2, cv2.COLOR_HLS2BGR)
return image2
if (os.path.isdir('./Resources/images/hist1')==False):
#kreiraj folder
os.mkdir('./Resources/images/hist1')
for i in range(853):
# Učitavanje slike
img = cv2.imread('./Resources/images/brightness2/maksssksksss' + str(i) + '.png')
dst = equalizeHistogram(img, 30)
print(i)
# Pohranjivanje slike
cv2.imwrite('./Resources/images/hist1/maksssksksss' + str(i) + '.png', dst)