Compile and test the bm3d Algorithm in Windows

Source: Internet
Author: User

1. Brief Introduction to bm3d and code

Currently, it is recognized as a good de-noise algorithm.

 

Source code (http://www.ipol.im/pub/art/2012/l-bm3d/) bm3d_src.zip)

 

This source code provides an implementation of the bm3d image denoising.

 

The code is compilable on Unix/Linux and Mac OS.

 

-Compilation.

Automatically compilation requires the make program.

 

-Library.

This Code requires the libpng library and the fftw library.

 

-Image format.

Only the PNG format is supported.

 

Ii. Compile and use in Windows

Platform: win7 + vs2010

Create a bm3dtest console project and add bmd3d_src to the project. We can see from the previous introduction that bm3d requires the PNG and fftw libraries, so we need to add these third-party libraries.

 

1. fftw3 library Configuration

Download fftw-3.3.3-dll32.zip (http://www.fftw.org/install/windows.html)

Follow the instructions to generate the DLL file (which already contains the Lib file)

Add lib Library

../Fftw-3.3.3-dll32/libfftw3-3.lib

../Fftw-3.3.3-dll32/libfftw3f-3.lib

../Fftw-3.3.3-dll32/libfftw3l-3.lib

Modify the Code as follows:

//! Allocate plan for fftw Library

// Fftwf_plan plan_2d_for_1 [nb_threads];

// Fftwf_plan plan_2d_for_2 [nb_threads];

// Fftwf_plan plan_2d_inv [nb_threads];

// Modified by loadstar

Fftwf_plan * plan_2d_for_1 = new fftwf_plan [nb_threads];

Fftwf_plan * plan_2d_for_2 = new fftwf_plan [nb_threads];

Fftwf_plan * plan_2d_inv = new fftwf_plan [nb_threads];

 

2.
How to Use the header file unistd. h in VC

The header file unistd. H is a Linux/Unix system call. It contains many prototype UNIX system service functions, such as open, read, write, _ exit, and getpid. A program that can be compiled in Linux that contains this header file has the following problems during compilation in VC:

 

Fatal error c1083: cannot open include file: 'unistd. H': no such file or directory

 

In fact, it is not difficult to solve this problem, as long as you add an unistd under your default library folder (such as D: \ Program Files \ Microsoft Visual Studio \ vc98 \ include. the content of the H file is as follows:

 

# Ifndef _ unistd_h

# DEFINE _ unistd_h

 

# Include <Io. h>

# Include <process. h>

 

# Endif/* _ unistd_h */

In this way, re-compile the program that contains unis. h.

 

3. PNG Library Compilation

Gzip, zlib, and PNG use the same compression algorithm deflate.

 

The libpng1250 (http://www.libpng.org/pub/png/libpng.html) folder contains the zlib project file (under the lpng1250 \ projects \ visualc71 folder) libpng project solution contains the project LibPNG. vcproj,
Pngtest. vcproj, zlib. vcproj, but this zlib project has some problems during compilation, so you are too lazy to solve it. You can directly use the zlib project in lpng1513.

Download lpng1513.zip (http://www.libpng.org/pub/png/libpng.html) unzip, by viewing the zlib. vcproj file, you can see that the project directory location:... \ zlib-1.2.5. In this directory, uncompress zlib127.zip (http://www.zlib.net/) because it uses a zlib-1.2.5 to change the zlib127 name to a zlib-1.2.5. Use vs2010 in lpng1513 to open the solution LibPNG. sln. Use DEBUG to compile the zlib project and generate the lpng1513 \ projects \ vstudio \ debug \ zlib. Lib file. (If a problem occurs when reading PNG images in this version, the PNG Library still uses lpng1250)

 

Open the lpng1250 Project (lpng1250 \ projects \ visualc71 \ LibPNG. sln)

Add the zlib header file:

Add the .. \ zlib-1.2.5 to the property-C/C ++-General-additional library inclusion directory (if there are other, modify it)

Select lib debug compilation to generate lpng1250 \ projects \ visualc71 \ win32_lib_debug \Libpngd. Lib

 

In the bm3dtest project:

Add header file

In properties-C/C ++-General-additional library inclusion directory add

.. \ Lpng1250

. \ Zlib-1.2.5

 

The directory where the project contains the. Lib file:

Property -- linker -- General -- Additional library directory

.. \ Lpng1250 \ projects \ visualc71 \ win32_lib_debug

.. \ Lpng1513 \ projects \ vstudio \ debug

Add lib File

Property -- linker -- input -- Additional dependency (libpngd. Lib zlib. Lib)

Add the corresponding DLL file (fftw) to the generated bm3dtest.exe directory. Find an image and try it.

 

Iii. Postscript:

1. Reference

Compiling and using zlib and libpng libraries in Windows

Http://blog.sina.com.cn/s/blog_659b2b3201013y9k.html

 

2. Use the libpng library generated by lpng1513 to read the image.

 

An error occurs during zlib project compilation in libpng1250.

The PNG format is only used to test the algorithm effect, so it will not take a long time to solve these problems. If you have time to find the answer to the question, please let us know :)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.