Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
370 views
1
from matplotlib import image, numpy, pyplot as mplot
2
3
class Image:
4
5
def __init__(self, data):
6
7
self.data = numpy.array(data[:,:,0:3]).astype('uint8')
8
9
def __repr__(self):
10
11
image.imsave("temp.png", self.data)
12
salvus.file("temp.png")
13
return ""
14
15
def __add__(self, other):
16
17
return Image(numpy.bitwise_xor(self.data, other.data) )
18
19
def size(self):
20
21
return (len(self.data), len(self.data[0]))
22
23
def RandomImage(m, n):
24
25
return Image(numpy.random.random_integers(255, size=(m,n,3)) )
26
27
def LoadImage(filename):
28
29
tmp = image.imread(filename)
30
return Image(image.imread(filename))
31