Discrete Wavelet Transform
Code and sample files for this demo can be downloaded from here. Code uses only libraries from the ACV-VirtualMachine.No extra libraries are needed.
You can unzip the code to any folder on your system. All paths used in the code are relative. We are using the folder "~/acv/code/dwt_demo/"
Compiling and running the code is fairly straight forward. You only need to run the following two commands:
acv@acv-vm:~/acv/code/dwt_demo/bin$ cmake ../src/wavelet_demo_others/ -- The C compiler identification is GNU 7.5.0 -- The CXX compiler identification is GNU 7.5.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") -- Found OpenCV: /usr/local (found version "4.4.0") -- Configuring done -- Generating done -- Build files have been written to: /home/acv/acv/code/dwt_demo/bin acv@acv-vm:~/acv/code/dwt_demo/bin$ make Scanning dependencies of target demo [ 16%] Building CXX object CMakeFiles/demo.dir/wavelet_demo.cpp.o [ 33%] Building CXX object CMakeFiles/demo.dir/wavelet_demo_others.cpp.o [ 50%] Building CXX object CMakeFiles/demo.dir/home/acv/acv/code/dwt_demo/src/util/BinaryHeap.cpp.o [ 66%] Building CXX object CMakeFiles/demo.dir/home/acv/acv/code/dwt_demo/src/util/ImageUtilities.cpp.o [ 83%] Building CXX object CMakeFiles/demo.dir/home/acv/acv/code/dwt_demo/src/util/LogManager.cpp.o [100%] Linking CXX executable demo [100%] Built target demo
After this, you just have to run the command "./demo" on the command line. You will not see any messages on running the code, but result files will show up in "/tmp/". Sample result files can be downloaded from here.
The first set of commands that get executed in the code can be seen in the file wavelet_demo.cpp, line 23 WaveletDemoOthers::processImage(inFileName, outFileName); The function processImage is called 9 times, using different files as input.
The function processImage is written in wavelet_demo_others.h, line 251. The processImage function is a wrapper to:
- Read the input image, convert it to single channel CV_32FC1, write the image to disk _orig_image.png (lines 252 to 267)
- Generate haar DWT coefficients. (lines 269 to 271)
- Set some of the DWT coefficients to zero. (lines 273 to 280)
- Compute inverse Haar DWT of the modified DWT coefficients (lines 282 to 283)
You can feel free to change the occlusion and understand how DWT models different patterns. Also feel free to change/experiment with different input images.
The second demo "image merging", is implemented in file wavelet_demo.cpp lines 31 to 59. This code does the following:
- The original image is read in lines 42-44
- The added image is read in lines 46-48
- The coefficients are added together in lines 50-53
- The inverted DWT image is generated and written in lines 58, 59
Comments
Post a Comment