I am looking for a strong baseline in image denoising and therefore wanted to have the BM3D algorithm in my benchmark.

These 2 python implementations:

have been unmaintained for a long time (and the second one is documented in what I think is chinese). I have experimented a bit with the first one without satisfactory results (see https://github.com/ericmjonas/pybm3d/issues/11 with non satisfactory fixes like clipping).

This package : https://pypi.org/project/bm3d/#description , doesn't have a documentation or source code easily findable.

Then I found this: https://docs.opencv.org/master/de/daa/group__xphoto.html#ga2fc5a9661c1338a823fb3290673a880d, in the docs of opencv but there is no indication as to how to use it and no examples in python. I saw this SO question but it's for a C++ implementation and I don't know how it would translate in Python because I am not familiar at all with opencv.

  • $\begingroup$ Have you found something? $\endgroup$
    – David
    Commented Nov 26, 2019 at 11:54
  • $\begingroup$ @David see the answer below $\endgroup$ Commented Nov 26, 2019 at 13:08

2 Answers 2


What I resorted to was using the PyPI package, which is advertised here: http://www.cs.tut.fi/~foi/GCF-BM3D/index.html#ref_software.

I dug a bit in the source code, and found that I could perform BM3D, in the following fashion:

import bm3d

denoised_image = bm3d.bm3d(image_noisy, sigma_psd=30/255, stage_arg=bm3d.BM3DStages.HARD_THRESHOLDING)

There are also some examples in the library's source code download.

I installed bm3d using pip (pip install bm3d) and needed OpenBlas (sudo apt-get install libopenblas-dev).

  • $\begingroup$ While this solution works, it doesn't implement the full bm3d algorithm, which is more powerful when used with stage_arg=bm3d.BM3DStages.ALL_STAGES. It is however twice slower with all stages. $\endgroup$ Commented Nov 26, 2019 at 16:45
  • $\begingroup$ Just as a confirmation, this method allows me to reproduce the results of arxiv.org/pdf/1902.02452.pdf (Table 1) and arxiv.org/pdf/1608.03981.pdf (Table 2) on the BSD68 dataset in terms of PSNR. $\endgroup$ Commented Nov 27, 2019 at 21:07
  • $\begingroup$ You can find an example of how I implemented it in those lines: github.com/zaccharieramzi/understanding-unets/blob/master/… $\endgroup$ Commented Jun 29, 2021 at 14:43
  • $\begingroup$ i used the same implementation but it doesn't denoise at all. $\endgroup$
    – Rima
    Commented Jan 28, 2023 at 13:20
  • $\begingroup$ @Rima You could open a new question with a minimal working example in order to let us help you properly $\endgroup$ Commented Jan 29, 2023 at 7:30

If you don't want to use the PyPI package for bm3d, you can use ffmpeg and run the bm3d filter as an OS command-

command="ffmpeg -i "+input_image_path+" -filter_complex bm3d=sigma=30/255:block=4:bstep=2:group=1:hdthr=10000:estim=basic /path/to/output/directory/output.png"    

This takes lesser computation time.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.