imgtoolpy package

Submodules

imgtoolpy.compress module

imgtoolpy.compress.compress(img, b)

Quantizes an image into 2^b clusters and return a version of the image (the same size as the original) where each pixel’s original colour is replaced with the nearest prototype colour.

Parameters
  • img (a (H,W,3) numpy array) – the image to be processed

  • b (int) – the desired number of bits

Returns

img

Return type

a (H,W,3) numpy array, returns the compressed image

Examples

>>> compress(img, 3)

imgtoolpy.sharpen module

imgtoolpy.sharpen.read_image(filename)
imgtoolpy.sharpen.sharpen(img)

Detects and enhances the edges in the image and returns a sharpened and monotoned version (the same size as the original).

Parameters

img (a (H,W,3) numpy array) – the image to be processed

Returns

(img2, img2_sharpened) – the original and sharpened images, both monotoned

Return type

two (H,W) numpy arrays

Examples

>>> sharpen(image)

imgtoolpy.crop module

imgtoolpy.crop.crop(image, width, height)

This function crop image to desired width and height by removing pixels from border.

imagenumpy.ndarray

An image as a 3D numpy array

widthint

Desired width of croped image

heightint

Desired height of croped image

numpy array

croped image as 3D array

>>> crop(image, width = 20, height = 20)

Module contents