Commit 21c6a08e authored by Taddeüs Kroes's avatar Taddeüs Kroes

Removed a bunch of unused imports.

parent d98cdc83
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"
\ No newline at end of file
print "around line", (where_it_went_wrong[1] - 2), "\n"
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)
......
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
)
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):
......
from Histogram import Histogram
from numpy import zeros, byte
from math import ceil
class LocalBinaryPatternizer:
......
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
\ No newline at end of file
print histograms
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()
\ No newline at end of file
normalized_character_image.show()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment