Giter Club home page Giter Club logo

bm3d's Introduction

% BM3D image denoising.

# ABOUT

* Author    : Marc Lebrun <[email protected]>
* Copyright : (C) 2011 IPOL Image Processing On Line http://www.ipol.im/
* Licence   : GPL v3+, see GPLv3.txt

# OVERVIEW

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

# UNIX/LINUX/MAC USER GUIDE

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

- Compilation. 
Automated compilation requires the cmake program.

- Libraries. 
This code requires the libpng libtiff libjpeg and libfftw librarers.

- Image formats. 
PNG, JPEG, TIFF (including floating point) formatis is supported. 
 
-------------------------------------------------------------------------
Usage:
1. Download the code package and extract it. Go to that directory. 

2. Compile the source code (on Unix/Linux/Mac OS). 
mkdir build; cd build; cmake ..; make

3. Run BM3D image denoising.
./bm3d
The generic way to run the code is:

./bm3d input.png sigma ImDenoised.png [ImBasic.png ]
-tau_2d_hard 2DtransformStep1 -useSD_hard 
-tau_2d_wien 2DtransformStep2 -useSD_wien 
-color_space ColorSpace

with :
- cinput.png is a noisy image;
- sigma is the value of the noise;
- ImBasic.png will contain the result of the first step of the algorithm;
- ImDenoised.png will contain the final result of the algorithm;
- 2DtransformStep1: choice of the 2D transform which will be applied in the 
     second step of the algorithm. You can choose the DCT transform or the 
     Bior1.5 transform for the 2D transform in the step 1 (tau_2D_hard = dct or bior) 
     and/or the step 2. (tau_2d_wien = dct or bior).
- useSD_hard: for the first step, users can choose if they prefer to use
     standard variation for the weighted aggregation (useSD1 = 1)
- 2DtransformStep2: choice of the 2D transform which will be applied in the 
     second step of the algorithm. You can choose the DCT transform or the 
     Bior1.5 transform for the 2D transform in the step 1 (tau_2D_hard = dct or bior) 
     and/or the step 2. (tau_2d_wien = dct or bior).
- useSD_wien: for the second step, users can choose if they prefer to use
     standard variation for the weighted aggregation (useSD2 = 1)
- ColorSpace: choice of the color space on which the image will be applied. 
     you can choose the colorspace for both steps between : rgb, yuv, ycbcr and opp.
- patch_size: overrides the default patch size
- nb_threads: specifies the number of working threads
- verbose: print additional information

Example, run
./BM3Ddenoising cinput.png 10 ImDenoised.png ImBasic.png -useSD_wien \
   -tau_2d_hard bior -tau_2d_wien dct -color_space opp

# ABOUT THIS FILE

Copyright 2011 IPOL Image Processing On Line http://www.ipol.im/

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.  This file is offered as-is,
without any warranty.

bm3d's People

Contributors

gauenk avatar gfacciol avatar timmeinhardt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bm3d's Issues

BM4D Extension

I am really liking the pybm3d wrapper. Thanks! Is there any motivation on your side of things to implement a pybm4d for image cubes?

Very suspicious piece of code

bm3d/bm3d.cpp

Line 1341 in 5c86dfe

//! Threshold distances in order to keep similar patches

            //! Threshold distances in order to keep similar patches
            for (int dj = -(int) nHW; dj <= (int) nHW; dj++)
            {
                for (int di = 0; di <= (int) nHW; di++)
                    if (sum_table[dj + nHW + di * Ns][k_r] < threshold)
                        table_distance.push_back(make_pair(
                                    sum_table[dj + nHW + di * Ns][k_r]
                                  , k_r + di * width + dj));

                for (int di = - (int) nHW; di < 0; di++)
                    if (sum_table[-dj + nHW + (-di) * Ns][k_r] < threshold)
                        table_distance.push_back(make_pair(
                                    sum_table[-dj + nHW + (-di) * Ns][k_r + di * width + dj]
                                  , k_r + di * width + dj));
            }

This is very suspicious. Since dj takes the same negative and positive values, it means the second if test is a duplicate of the first one, however it doesn't insert the same element. Wrong check ?

Precompute_BM function error?

Dear
Is there any error in line 1375?
for (int di = - (int) nHW; di < 0; di++)

**// if (sum_table[-dj + nHW + (-di) * Ns][k_r] < threshold) //should be

if (sum_table[-dj + nHW + (-di) * Ns][k_r + di * width + dj] < threshold)**
table_distance.push_back(make_pair(
sum_table[-dj + nHW + (-di) * Ns][k_r + di * width + dj]
, k_r + di * width + dj));

The code generates blocks of -nan for some input images

nantest.zip
I've found some images (typically mono images with mostly low pixel values and high dynamic range, such as unstretched astronomical images, when processed with BM3D, generate blocks of -nan in the output. Looking at the basic output, the -nan values appear to start off in the first stage of the algorithm usually as single pixels and then presumably get spread to a whole block in the second stage where processing of a block encounters the pixel with -nan value. An example file that creates -nan results is attached: the sigma for this file is 0.000105 (using bgnoise measurement from Siril).

Saving as JPG results in image that can not be opened

The ./bm3d executable seems to have a problem with saving an image in the JPG format. I tried to denoise this image which worked only if I set the output filename to *.png but not *.jpg. The denoising seems to work in both cases but for the latter the saved image can not be opened.

Values of N passed to sub_divide seem wrong

In bm3d.cpp, lines 272, 304, 307 and 341 seem to do the following:

  • chop the image into pieces with border 2 * nWien
  • reassemble the image based on subimages with borders 2 * nHard
  • chop the image into subimages with borders 2 * nHard
  • reassemble the image based on subimages with borders 2 * nWien

Shouldn't the values of N for chopping the image up and reassembling it be the same? In practice it doesn't matter because nWien and nHard are both defined as the same value, but if one value was changed it seems the result would not be good. I think the parameters on those lines should respectively be 2 * nHard, 2 * nHard, 2 * nWien, 2 * nWien.

about parameter tauMatch

Hi, I'm little confused about the value of tauMatch (function bm3d_1st_step):
const float tauMatch = (chnls == 1 ? 3.f : 1.f) * (sigma_table[0] < 35.0f ? 2500 : 5000)
I'm just wondering why do we use tauMatch = 3\sigma when the input image has single channel?
Thank you!

RAM problem with large images

I work with large 32 bits floating point TIFF. The code works great with 1000x1000 pixels images, while with larger ones (e.g. 5000x5000, 10000x10000) it uses the 99%-100% of the RAM (32GB) making the entire system unresponsive for several hours (16+ hours) and in the end terminating the process uncompleted.
I use other noise reduction algorithms on such images, but it is the first time I've this kind of problem.
Any suggestion or indication? Perhaps some parameter to set or similar? Is the code suitable for images larger than 1000x1000?
Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.