imghelp.imgcompress

Module Contents

Functions

ImgCompress(img, method, level=1)

Image compression using different compression method.

imghelp.imgcompress.ImgCompress(img, method, level=1)[source]

Image compression using different compression method. This function compress image to a user defined compression level.

SVD Method:

SVD (Singular Value Decomposition) on RGB image. Note: Actual image memory size is not changed from this function.

It does not handle the Jpeg compression algorithm

Resize:

Resize image to different size using interval pixel selection method.

Parameters
  • img (numpy.array) – Input image for compression.

  • method (string) – Compression methods: Resize, SVD

  • level (int) – Level of compression: 1-High, 2-Med, 3-Low

Returns

The compressed image.

Return type

numpy.array

Examples

>>> import matplotlib.pyplot as plt
>>> from imghelp.ImgCompress import ImgCompress
>>> image = plt.imread('../test_img/ubc.jpeg')
>>> plt.imshow(image) #show the image
>>> img_comp = ImgCompress(image, method='resize', level=1)
>>> plt.imshow(img_comp) #show the compressed (resized) image