Image_Processing package

Submodules

Image_Processing.center_image module

Center images

A module to crop and center images. This is a necessary preprocessing step for the input data to resemble training data.

Image_Processing.center_image.add_padding(img, pad_t, pad_r, pad_b, pad_l)

Add padding of zeroes to an image. Add padding to an array image.

Parameters:
  • img (ndarray) – Numpy array of input image which needs to be padded by zeros
  • pad_t (int) – Number of pixels of paddding on top of the image
  • pad_r (int) – Number of pixels of paddding beneath of the image
  • pad_b (int) – Number of pixels of paddding to the right of the image
  • pad_l (int) – Number of pixels of paddding to the left of the image
Returns:

Numpy array of padded image

Image_Processing.center_image.center_image(img)

Return a centered image.

Parameters:img (ndarray) – Numpy array of input image which needs to be centered
Returns:Centered image’s Numpy array

Image_Processing.imgpreprocess module

imgpreprocess.py

A module to preprocess and segement an image containing digits in several lines into lines and further into separate digits. These segmented images of digits are then fed to neural networks for recognition.

class Image_Processing.imgpreprocess.Preprocess(imagepath)

Bases: object

Preprocess class is initialized by passing an image as argument.

segment_lines()

The image containing text is segmented into lines and returns a list of the lines

Returns:List of arrays, each array is a line from image
Image_Processing.imgpreprocess.binaryimg(image)

Converts grayscale image to binary image , it gives 1 for black and zero for white.

Parameters:image (array) – represents the image to be converted to binary
Image_Processing.imgpreprocess.cropimg(image)

Crops a binary image tightly

Parameters:image (array) –
Image_Processing.imgpreprocess.last_char(img)

Takes a line from a segemented image and returns last character in the line

Parameters:img (array) –
Image_Processing.imgpreprocess.last_line(img)

Takes cropped binary image as input and gives the segment of image containing last line of text

Parameters:img (array) –
Image_Processing.imgpreprocess.segment_characters(line)

Takes a line from a segemented image and returns a list of characters in the line.

Parameters:line (array) –

Module contents