Przeglądaj źródła

Removed a bunch of unused imports.

Taddeüs Kroes 14 lat temu
rodzic
commit
21c6a08e21

+ 3 - 3
src/Error.py

@@ -1,4 +1,4 @@
-import traceback, os.path
+import traceback
 
 class Error:
     def __init__(self, message=None):
@@ -7,11 +7,11 @@ class Error:
         where_it_went_wrong = stack[1]
 
         if message:
-          print message, "\n"
+            print message, "\n"
 
         print "Error in", origin_of_call[0], "on line", origin_of_call[1]
         print " : ", origin_of_call[3], "\n"
 
         # Inside try function, so -2 lines as exept and Error() are 2 lines
         print "Function called in", where_it_went_wrong[0]
-        print "around line", (where_it_went_wrong[1] - 2), "\n"
+        print "around line", (where_it_went_wrong[1] - 2), "\n"

+ 8 - 8
src/GaussianFilter.py

@@ -1,12 +1,12 @@
 from GrayscaleImage import GrayscaleImage
 from scipy.ndimage import convolve1d
-from pylab import ceil, zeros, pi, e, exp, sqrt, array
+from pylab import ceil, zeros, pi, exp, sqrt, array
 
 class GaussianFilter:
 
     def __init__(self, scale):
         self.scale = scale
-        
+
     def gaussian(self, x):
         '''Return the value of a 1D Gaussian function for a given x and scale'''
         return exp(-(x ** 2 / (2 * self.scale ** 2))) / (sqrt(2 * pi) * self.scale)
@@ -15,12 +15,12 @@ class GaussianFilter:
         '''Sample a one-dimensional Gaussian function of scale s'''
         radius = int(ceil(3 * self.scale))
         size = 2 * radius + 1
-        
+
         result = zeros(size)
-        # Sample the Gaussian function    
+        # Sample the Gaussian function
         result = array([self.gaussian(x - radius) for x in xrange(size)])
         # The sum of all kernel values is equal to one
-        result /= result.sum() 
+        result /= result.sum()
 
         return result
 
@@ -29,15 +29,15 @@ class GaussianFilter:
         kernel = self.get_1d_gaussian_kernel()
         image = convolve1d(image.data, kernel, axis=0, mode='nearest')
         return GrayscaleImage(None, convolve1d(image, kernel, axis=1, mode='nearest'))
-        
+
     def filter(self, image):
         kernel = self.get_1d_gaussian_kernel()
         image.data = convolve1d(image.data, kernel, axis=0, mode='nearest')
         image.data = convolve1d(image.data, kernel, axis=1, mode='nearest')
-        
+
     def get_scale(self):
       return self.scale
-      
+
     def set_scale(self, scale):
         self.scale = float(scale)
 

+ 4 - 6
src/LetterCropper.py

@@ -1,12 +1,10 @@
-from copy import deepcopy
 from Rectangle import Rectangle
-from GrayscaleImage import GrayscaleImage
 
 class LetterCropper:
 
     def __init__(self, threshold = 0.9):
         self.threshold = threshold
-        
+
     def crop_to_letter(self, image):
         self.image = image
         self.determine_letter_bounds()
@@ -24,10 +22,10 @@ class LetterCropper:
                 if y < min_y: min_y = y
                 if x > max_x: max_x = x
                 if y > max_y: max_y = y
-        
+
         self.letter_bounds = Rectangle(
-            min_x, 
-            min_y, 
+            min_x,
+            min_y,
             max_x - min_x ,
             max_y - min_y
         )

+ 6 - 7
src/LicensePlate.py

@@ -1,17 +1,16 @@
-from pylab import array, zeros, inv, dot, svd, shape, floor
+from pylab import array, zeros, inv, dot, svd, floor
 from xml.dom.minidom import parse
-from Error import Error
 from Point import Point
 from Character import Character
 from GrayscaleImage import GrayscaleImage
 from NormalizedCharacterImage import NormalizedCharacterImage
 
-'''
-    Creates a license plate object based on an XML file. The image should be
-    placed in a folder 'images' the xml file in a folder 'xml'
+"""
+Creates a license plate object based on an XML file. The image should be
+placed in a folder 'images' the xml file in a folder 'xml'
 
-    TODO: perhaps remove non required XML lookups
-'''
+TODO: perhaps remove non required XML lookups
+"""
 class LicensePlate:
 
     def __init__(self, folder_nr, file_nr):

+ 0 - 1
src/LocalBinaryPatternizer.py

@@ -1,5 +1,4 @@
 from Histogram import Histogram
-from numpy import zeros, byte
 from math import ceil
 
 class LocalBinaryPatternizer:

+ 1 - 4
src/LocalBinaryPatternizerTest.py

@@ -1,12 +1,9 @@
 from GrayscaleImage import GrayscaleImage
 from LocalBinaryPatternizer import LocalBinaryPatternizer
-from LetterCropper import LetterCropper
-from matplotlib.pyplot import imshow, subplot, show, axis, bar
-from numpy import arange
 
 image = GrayscaleImage("../images/test.png")
 
 lbp = LocalBinaryPatternizer(image)
 histograms = lbp.create_features_vector()
 
-print histograms
+print histograms

+ 2 - 3
src/combined_test.py

@@ -1,7 +1,6 @@
 from GrayscaleImage import GrayscaleImage
-from NormalizedCharacterImage import NormalizedCharacterImage 
-from LetterCropper import LetterCropper
+from NormalizedCharacterImage import NormalizedCharacterImage
 
 image = GrayscaleImage("../images/test10.png")
 normalized_character_image = NormalizedCharacterImage(image)
-normalized_character_image.show()
+normalized_character_image.show()