Changeset 5
- Timestamp:
- 09/23/07 04:52:51 (1 year ago)
- Files:
-
- wavelet.py (modified) (6 diffs)
- waveletUnitTest.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wavelet.py
r4 r5 23 23 24 24 """ 25 load the image from given path, using PIL, converts it into YIQ colour space25 Load the image from given path, using PIL, converts it into YIQ colour space 26 26 """ 27 27 rgb2yiq = ( … … 33 33 im = Image.open(path) 34 34 im = im.resize(config.img_size) 35 im =im.convert("RGB", rgb2yiq)35 im = im.convert("RGB", rgb2yiq) 36 36 37 37 self.data = im.getdata() … … 41 41 42 42 def cleanup(self): 43 """frees wavelets data and reverts image to rgb""" 43 """ 44 Frees wavelets data and reverts image to rgb. This method should only be called 45 *after* calling .signature() at least once 46 """ 44 47 self.wavelets = None 45 48 self.data = None 46 49 47 50 def pix_sum(self, x,y): 48 """ returns a tuple which is the sum of the tuples given"""51 """Returns a tuple which is the sum of the tuples given""" 49 52 return ((x[0])+y[0], x[1]+y[1], x[2]+y[2]) 50 53 51 54 def pix_diff(self, x,y): 52 """ returns a tuple which is the difference of the tuples given"""55 """Returns a tuple which is the difference of the tuples given""" 53 56 return ((x[0])-y[0], x[1]-y[1], x[2]-y[2]) 54 57 55 58 def signature(self): 56 """ returns a signature tuple based on the input which is expected to be the59 """Returns a signature tuple based on the input which is expected to be the 57 60 wavelet transform of an image 58 61 """ … … 101 104 102 105 def transform_array(self, input): 103 """ docstring for transform a single array"""106 """Performs wavelet transform on the input, destorys input""" 104 107 length = len(input) 105 108 output = [0]*length … … 124 127 def transform(self): 125 128 """ 126 performs a wavelet transform on the given image129 Performs a wavelet transform on the given image 127 130 """ 128 assert (self.data != None)131 assert self.data != None, "Did you call .cleanup() before .signature()?" 129 132 input = list(self.data) 130 133 … … 161 164 162 165 def compare(self, other): 163 """ compars this wavelet transform to another, returning a tuple of similarness"""166 """Compars this wavelet transform to another, returning a tuple of similarness""" 164 167 sig = other.signature() 165 168
