Giter Site home page Giter Site logo

bm3d-gpu's Introduction

BM3D-GPU

CUDA-accelerated implementation of BM3D image denoising method

Author : David Honzátko [email protected]

Unix/Linux User Guide

The code is compilable on Unix/Linux.

  • Compilation. Automated compilation requires the cmake program.

  • Libraries. This code requires the CUDA toolkit installed.

  • Image format. All the image formats supported by the Cimg library. For users that have convert or gm installed, it supports most of the image formats. Otherwise we recommend to use the .bmp format.

Usage:

  1. Download the code package and extract it. Go to that directory.

  2. Create build directory, create the makefiles using cmake and compile the application Run

mkdir build
cd build
cmake ..
make
  1. Run CUDA-accelerated BM3D image denoising application
./bm3d

The generic way to run the code is:

./bm3d NoisyImage.png DenoisedImage.png sigma [color [twostep [quiet [ReferenceImage]]]]

Options:

  • color - color image denoising (experimental only)
  • twostep - process both steps of the BM3D method
  • quiet - no information about the state of processing is displayed
  • ReferenceImage - if provided, computes and prints PSNR between the ReferenceImage and DenoisedImage

Example of gray-scale denoising by the fisrt step of BM3D:

./bm3d lena_20.png lena_den.png 20

Example of color denoising by both steps of BM3D:

./bm3d lena_20_color.png lena_den_color.png 20 color twostep

Example of grayscale denoising by both steps of BM3D with PSNR computation:

./bm3d lena_25.png lena_den.png 25 nocolor twostep quiet lena.png

Citation

If you find this implementation useful please cite the following paper in your work:

@article{bm3d-gpu,
    author = {Honzátko, David and Kruliš, Martin},
    year = {2017}, month = {11},
    title = {Accelerating block-matching and 3D filtering method for image denoising on GPUs},
    booktitle = {Journal of Real-Time Image Processing}
}

bm3d-gpu's People

Contributors

dawyd 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bm3d-gpu's Issues

Illegal memory access on some images

I get the following error:

Sigma = 10
Number of Steps: 2
Color denoising: yes
Noise variance for individual channels (YCrCb if color): 32 29 33 
width: 4231 height: 3051
Shared memory : 46KB/48KB
Number of warps: 20
Processing 0%terminate called after throwing an instance of 'thrust::system::system_error'
  what():  bm3d.hpp(788):: an illegal memory access was encountered
test_bm3d.sh: line 6:  5767 Aborted                 (core dumped) bm3d ${NOISYTESTDIR}/${TESTSET}/${TESTIMG} results/test2/bm3d-${SIGMA}/${TESTIMG} ${SIGMA} color twostep

when trying to denoise any of the images in that set https://commons.wikimedia.org/wiki/File:NIND_MuseeL-skull-C500D_ISO200.jpg

Sigma argument not used for gray value images?

Hi! Thanks for this great implementation!
However, I noticed that changing sigma did not change the output when denoising gray scale images. From looking into the code, I think the reason is that the parameter sigma is only actually used if channels == 3, while it is initialized to 625 otherwise. I changed it in my local copy of the repository, and it seems to have fixed it, although based on the results I am still not 100% sure I really replaced it with the correct values (from my understanding, sigma2 should simply be sigma squared, i.e. the variance).

It concerns lines 49-64 in main_nodisplay.cpp (I indicate my "fix" as a comment in line 53 (line 5 of the snippet))

	//Allocate images
	CImg<unsigned char> image(argv[1]);
	CImg<unsigned char> image2(image.width(), image.height(), 1, channels, 0);
	std::vector<unsigned int> sigma2(channels);
	sigma2[0] = 25 * 25;   // <---    sigma2[0] = sigma * sigma;     
	
	//Convert color image to YCbCr color space
	if (channels == 3)
	{
		image = image.get_channels(0, 2).RGBtoYCbCr();
		//Convert the sigma^2 variance to the YCbCr color space
		long s = sigma * sigma;
		sigma2[0] = ((66l*66l*s + 129l*129l*s + 25l*25l*s) / (256l*256l));
		sigma2[1] = ((38l*38l*s + 74l*74l*s + 112l*112l*s) / (256l*256l)),
		sigma2[2] = ((112l*112l*s + 94l*94l*s + 18l*18l*s) / (256l*256l));
	}

It would be great if you could verify the issue and that the fix is correct.

16-bit tiff file

This project is not working with 16-bit tiff images. It is still doing something and the output is a 8-bit tiff pretty close to a random image.

undefined reference to `jpeg_std_error'

hello,

this error appears with make command:

[100%] Linking CXX executable bm3d
/usr/bin/ld: CMakeFiles/bm3d.dir/src/main_nodisplay.cpp.o: in function `cimg_library::CImg<unsigned char>::_save_jpeg(_IO_FILE*, char const*, unsigned int) const':
main_nodisplay.cpp:(.text._ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj[_ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj]+0x26b): undefined reference to `jpeg_std_error'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj[_ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj]+0x28b): undefined reference to `jpeg_CreateCompress'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj[_ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj]+0x2d4): undefined reference to `jpeg_stdio_dest'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj[_ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj]+0x31a): undefined reference to `jpeg_set_defaults'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj[_ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj]+0x345): undefined reference to `jpeg_set_quality'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj[_ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj]+0x359): undefined reference to `jpeg_start_compress'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj[_ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj]+0x808): undefined reference to `jpeg_write_scanlines'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj[_ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj]+0x81c): undefined reference to `jpeg_finish_compress'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj[_ZNK12cimg_library4CImgIhE10_save_jpegEP8_IO_FILEPKcj]+0x844): undefined reference to `jpeg_destroy_compress'
/usr/bin/ld: CMakeFiles/bm3d.dir/src/main_nodisplay.cpp.o: in function `cimg_library::CImg<unsigned char>::_load_jpeg(_IO_FILE*, char const*)':
main_nodisplay.cpp:(.text._ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc[_ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc]+0x100): undefined reference to `jpeg_std_error'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc[_ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc]+0x233): undefined reference to `jpeg_CreateDecompress'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc[_ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc]+0x24c): undefined reference to `jpeg_stdio_src'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc[_ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc]+0x260): undefined reference to `jpeg_read_header'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc[_ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc]+0x26f): undefined reference to `jpeg_start_decompress'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc[_ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc]+0x4da): undefined reference to `jpeg_read_scanlines'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc[_ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc]+0x799): undefined reference to `jpeg_finish_decompress'
/usr/bin/ld: main_nodisplay.cpp:(.text._ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc[_ZN12cimg_library4CImgIhE10_load_jpegEP8_IO_FILEPKc]+0x7a8): undefined reference to `jpeg_destroy_decompress'
/usr/bin/ld: CMakeFiles/bm3d.dir/src/main_nodisplay.cpp.o: in function `cimg_library::CImg<unsigned char>::_cimg_jpeg_error_exit(jpeg_common_struct*)':
main_nodisplay.cpp:(.text._ZN12cimg_library4CImgIhE21_cimg_jpeg_error_exitEP18jpeg_common_struct[_ZN12cimg_library4CImgIhE21_cimg_jpeg_error_exitEP18jpeg_common_struct]+0x45): undefined reference to `jpeg_destroy'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/bm3d.dir/build.make:129: bm3d] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/bm3d.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

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.