-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdi.py
More file actions
44 lines (39 loc) · 1.45 KB
/
pdi.py
File metadata and controls
44 lines (39 loc) · 1.45 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
38
39
40
41
42
43
44
import numpy as np
class PDI():
def alargamento_constrate(image,limiar):
height, width = image.shape
new_image = image.copy()
for h in range(0,height):
for w in range(0,width):
if image[h, w] < limiar:
new_image[h,w] = 0
elif image[h, w] == limiar:
new_image[h,w] = 128
else:
new_image[h,w] = 255
return new_image
def log_transformation(image,constant = 1):
height, width = image.shape
new_image = image.copy()
for h in range(0,height):
for w in range(0,width):
new_image[h,w] = constant * np.log10((image[h,w]/255) + 1)*255
return new_image
def powerrating_transformation(image,gama, constant = 1):
height, width = image.shape
new_image = image.copy()
for h in range(0,height):
for w in range(0,width):
new_image[h,w] = constant * ((image[h,w]/255) ** gama) * 255
return new_image
def bits_plane(image,plane):
height, width = image.shape
new_image = image.copy()
for h in range(0,height):
for w in range(0,width):
bin_number = '{0:08b}'.format(image[h,w])
if int(bin_number[7 - plane]) == 1:
new_image[h,w] = 255
else:
new_image[h,w] = 0
return new_image