Utils
ImageMosaic class
docclean.utils.ImageMosaic(image)
Image Mosaic class to make mosaic out of large images
Args:
image (np.ndarray): Numpy image array
Attributes:
input_shape: Input image size
extended_image: pads the images to the nearest powers of two.
get_powers_of_two method
ImageMosaic.get_powers_of_two(number)
Get nearest power of two
Args:
number (int): Input number
Returns:
int: Nearest power of two
normalise method
ImageMosaic.normalise(image)
Normalise the image between one and zero.
Args:
image (np.ndarray): Image array
Returns:
np.ndarray: Normalized array
extend_image method
ImageMosaic.extend_image()
Pad the image to neast power to two.
Returns:
np.ndarray: Numpy array of extended image
make_patches method
ImageMosaic.make_patches()
Makes patches of the image
Returns:
np.ndarray: Patches
combine_patches method
ImageMosaic.combine_patches(patches)
Combine patches back to image
Args: patches (np.ndarray): Patches array
Returns:
np.ndarray: Original Image
normed_to_uint8 function
docclean.utils.normed_to_uint8(image)
Scale normalised image to unit8 array
Args:
image (np.ndarray) : image array
Returns:
np.ndarray: uint8 scaled array
get_png_data function
docclean.utils.get_png_data(fname)
Read png data into tf tensors.
Args:
fname (str): file path
Returns:
tf.Tensor: image tensor
get_kaggle_paired_data function
docclean.utils.get_kaggle_paired_data(fname)
Get kaggle paired data
Args:
fname (str): File Name
Returns:
Tuple [tf.Tensor, tf.Tensor] : Dirty and Claen image
get_kaggle_data function
docclean.utils.get_kaggle_data(fname)
Read kaggle png data into tf tensors.
Args:
fname (str): file path
Returns:
tf.Tensor: image tensor
normalize function
docclean.utils.normalize(image)
Normalise the image by casting it to float and scaling between -1 and 1
Args:
image (tf.Tensor): imgae tensor
Returns:
tf.Tensor: Normalised image
books_crop_and_augment function
docclean.utils.books_crop_and_augment(image, size=(256, 256), num_boxes=1, rotate=True, flips=True)
Augments the book pages by zooming, cropping, rotating and fliiping
Args:
image (tf.Tensor) : image tensor
size (Tuple) : size to crop the image tensor
num_boxes (int): Number of patches from the image
rotate (bool): If random 90 degree rotations
flips (bool): If random LR and UD flips
Returns:
tf.Tensor: Augmented image
kaggle_paired_augment function
docclean.utils.kaggle_paired_augment(dirty, clean, size=(256, 256), rotate=True, flips=True)
Augments the book pages by zooming, cropping, rotating and fliiping
Args:
dirty (tf.Tensor) : image tensor
clean (tf.Tensor) : image tensor
size (Tuple) : size to crop the image tensor
rotate (bool): If random 90 degree rotations
flips (bool): If random LR and UD flips
Returns:
tf.Tensor: Augmented image