In this recipe, you will learn how to use wavelets to transform an image and discard the lower-order bits from the output of the transform, so that most of its values are zero (or very small), but most of the signal (pixels) is preserved. We shall use the mahotas library functions for the demonstration.
Compressing an image using wavelets
Getting ready
In this recipe, we will use the cameraman grayscale image as input. Let's get started by importing the required libraries and modules:
import numpy as np
import mahotas
from mahotas.thresholding import soft_threshold
from matplotlib import pyplot as plt
import os