/
GHBSM partB.py
99 lines (62 loc) · 1.51 KB
/
GHBSM partB.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from SimpleCV import Camera, Display, Image
import numpy as N
#import sklearn as sk
from sklearn import *
#from scipy.sparse import *
#from scipy import *
from matplotlib import pylab
import cv2
#from sklearn.utils.validation import check_arrays
#from skimage import data
#from skimage import filters #
c = Camera()
def foto(c):
img = c.getImage()
img.show()
return img
#a=foto(c)
a=Image("hola5Gray.png")
imgGray=a
##imgGray=a.grayscale()
#imgGray.save("hola42AGray.png")
#a.save("holaA42.png")
def histograma(hist):
hist=hist.histogram(255)
## hist.save("hola4Hist.txt")
pylab.plot(hist)
pylab.draw()
pylab.pause(0.0001)
##b=histograma(imgGray)
b = imgGray.binarize(50)
ainv = imgGray.binarize(100)
a=ainv.__invert__()
##b.show()
##pylab.figure(1)
##pylab.subplot(311), a.show(), pylab.title('Imagen Original')
##a.show()
##histograma(imgGray)
##pylab.subplot(312), b.show(), pylab.title('Imagen Invertida')
##b.show()
a.save("a.png")
b.save("b.png")
ainv.save("ainv.png")
orig = cv2.imread("hola5Gray.png")
ainv = cv2.imread("ainv.png")
h=imgGray.histogram(255)
a = cv2.imread("a.png")
b = cv2.imread("b.png")
c=cv2.add(a,b)
pylab.subplot(2,2,1)
pylab.imshow(orig)
pylab.title('Imagen Original')
pylab.subplot(2,2,2)
pylab.imshow(a)
pylab.title('Im Bin(100) e invertida')
pylab.subplot(2,2,3)
pylab.imshow(b)
pylab.title('Imagen Binarizada (50)')
pylab.subplot(2,2,4)
pylab.imshow(c)
pylab.title('Imagen Segmentada Sustraida')
pylab.show()
# histResta=histB-histA