2012年7月30日 星期一

[724] Wavelet transform in Python

I was recently finished the job that making the wavelet transform (2dwavelet97lift.py) appliable for any size and any aspect ratio of images. Before that, of course, I’ve spent much time for understading basics of descrete wavelet transformation. Using the sample code of CDF 9/7 Discrete Wavelet Transform which the file named “2dwavelet97lift.py”. Indeed, it is a 2D wavelet transform but only for square image and the length must be 23 while it does 3 level transform. My job is split the 2D transform into two 1D transform while its 2D transform transpose the image two times which only works on square image. This can solve the problem and be applied for any aspect ratio of images. Let’s see the result of sample image which in size of 1600x1000.

2d_a1 original image

2d_a1_fwt image after fwt

2d_a1_iwt image after iwt

How about the other problem? In this, I use a stupid but really working way: resize it! Resize to what size? It depends on the level of transformation. We can resize the length of the image to the multiplication of (2 << level) and must larger than the original.

You can download the sample program here.
Python 2.7 and PIL are required to be installed.
Click the cmd file to run and you can also edit the parameters:
  pyc_filename [image_filename] [transform_level]

2021年11月 6N6P真空管耳擴

  今年某月看到下面這位大大的貼文就想造出來一台真空管耳擴。 OTL WCF headphone amp build + awesome prototype material 從規劃製作、蒐集元件到動手製作前前後後大約花了三個月吧! 真正動手組裝大概是11月初的事情,短短一兩的禮...