Changeset 5

Show
Ignore:
Timestamp:
09/23/07 04:52:51 (1 year ago)
Author:
steve
Message:

Created unit test to ensure correctness of signature generation.
More and better comments.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wavelet.py

    r4 r5  
    2323                 
    2424                """ 
    25                 load the image from given path, using PIL, converts it into YIQ colour space 
     25                Load the image from given path, using PIL, converts it into YIQ colour space 
    2626                """ 
    2727                rgb2yiq = ( 
     
    3333                im = Image.open(path) 
    3434                im = im.resize(config.img_size) 
    35                 im=im.convert("RGB", rgb2yiq) 
     35                im = im.convert("RGB", rgb2yiq) 
    3636                 
    3737                self.data = im.getdata() 
     
    4141         
    4242        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                """ 
    4447                self.wavelets = None 
    4548                self.data = None 
    4649                 
    4750        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""" 
    4952                return ((x[0])+y[0], x[1]+y[1], x[2]+y[2]) 
    5053         
    5154        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""" 
    5356                return ((x[0])-y[0], x[1]-y[1], x[2]-y[2]) 
    5457         
    5558        def signature(self): 
    56                 """returns a signature tuple based on the input which is expected to be the 
     59                """Returns a signature tuple based on the input which is expected to be the 
    5760                wavelet transform of an image 
    5861                """ 
     
    101104         
    102105        def transform_array(self, input): 
    103                 """docstring for transform a single array""" 
     106                """Performs wavelet transform on the input, destorys input""" 
    104107                length = len(input) 
    105108                output = [0]*length 
     
    124127        def transform(self): 
    125128                """ 
    126                 performs a wavelet transform on the given image 
     129                Performs a wavelet transform on the given image 
    127130                """ 
    128                 assert(self.data != None) 
     131                assert self.data != None, "Did you call .cleanup() before .signature()?" 
    129132                input = list(self.data) 
    130133                 
     
    161164                                 
    162165        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""" 
    164167                sig = other.signature() 
    165168