-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransformacaoDeIntensidade.py
49 lines (35 loc) · 1.07 KB
/
TransformacaoDeIntensidade.py
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
45
46
47
48
49
import math
import numpy as np
from codigos.Utils import exibir_imagem
def transformacao_log(img):
y, z, rgb = img.shape
out = np.zeros((y, z, rgb), dtype=np.uint8)
c = 100
# s = c * math.log10(1 + r)
for i in range(y):
for u in range(z):
for j in range(rgb):
r = img.item(i, u, j)
s = c * math.log10(1 + r)
if s > 255:
out.itemset((i, u, j), 255)
else:
out.itemset((i, u, j), s)
exibir_imagem(out, "transformacao log")
return out
def transformacao_pot(img):
y, z, rgb = img.shape
out = np.zeros((y, z, rgb), dtype=np.uint8)
c = 1
y1 = 1
for i in range(y):
for u in range(z):
for j in range(rgb):
r = img.item(i, u, j)/255
s = c * (r**y1)
if s > 255:
out.itemset((i, u, j), 255)
else:
out.itemset((i, u, j), s*255)
exibir_imagem(out, "transformacao pot")
return out