alasdairnewson / film_grain_rendering_gpu Goto Github PK
View Code? Open in Web Editor NEWGPU implementation of film grain rendering
GPU implementation of film grain rendering
━━━━━━━━ README ━━━━━━━━ Table of Contents ───────────────── 1 About 2 Overview 3 Requirement 4 Compilation 5 Usage .. 5.1 Film grain rendering ..... 5.1.1 Description 1 About ═══════ Author : Alasdair Newson <[email protected]>, Julie Delon <[email protected]> and Bruno Galerne <[email protected]> Copyright: (C) 2016 IPOL Image Processing On Line [http://www.ipol.im/] Licence : GPL V3+ 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. 2 Overview ══════════ This source code provides an implementation of the film grain rendering algorithm of Newson et al. The 'bin/film_grain_rendering_main' program reads an input image, and adds film grain noise/texture to this image. Only PNG or TIFF (black and white or colour) images are handled. 3 Requirement ═════════════ The code is written in UTF8 C++, and should compile on any system with an UTF8 C++ compiler. The libpng and libtiff header and libraries are required on the system for compilation and execution. On Linux, just use your package manager to install it: ┌──── │ sudo apt-get install libpng │ sudo apt-get install libtiff └──── For more information, see [http://www.libpng.org/pub/png/libpng.html] and [http://www.libtiff.org/]. 4 Compilation ═════════════ To compile the code, use the provided makefile, with the command 'make'. The makefile will produce a program called : 'bin/film_grain_rendering_main'. It is possible to compile the program using OpenMP with the command 'make OMP=1'. The 'film_grain_rendering_main' program is used to render an input image with film grain. 5 Usage ═══════ 5.1 Film grain rendering ────────── 5.1.1 Description ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ The 'film_grain_synthesis_main' program can be called, for example, in the following manner : ┌──── │ bin/film_grain_rendering_main input.tiff output.png -r "0.1" -grainSigma "0.0" -filterSigma "0.8" -zoom "2.0" -algorithmID "0" -NmonteCarlo "100" └──── input.tiff : input image. Can be a tiff or png image. output.tiff : output, rendered image. A tiff image. Parameters [default value] -r : average grain radius [0.1] -grainSigma : standard deviation of the grain radii [0.0] -filterSigma : standard deviation (in pixels) of the Gaussian filter applied to the continuous grain model [0.8] -zoom : zoom coefficient which increases the resolution of the output image with respect to the input image resolution [1.0] -algorithmID : identifier of the algorithm used. Can be equal to 0 (pixel-wise algorithm) or 1 (grain-wise algorithm) [0] -NmonteCarlo : number of Monte Carlo simulations. This influences the quality of the result (the higher the number, the better the quality, but the longer it takes) [800] #Further parameters concerning zoom and resolution. These parameters are to be specified if the user wishes to zoom on a specific region of the input image and only carry out the rendering in this region. In this case, you should also specify the number of pixels in the x and y directions (nX, nY). #Note, if the 'zoom' parameter is activated, then the following parameters are ignored, as they may potentially be incompatible with the zoom. -nX : number of pixels in the x direction (number of columns). By default, this is set to the same number as in the input image. -nY : number of pixels in the y direction (number of rows). By default, this is set to the same number as in the input image. -xA : x coordinate of the upper left corner of the rectangle of the region in which the film grain rendering is carried out [0.0] -yA : y coordinate of the upper left corner of the rectangle of the region in which the film grain rendering is carried out [0.0] -xB : x coordinate of the bottom right corner of the rectangle of the region in which the film grain rendering is carried out [nX] -yB : y coordinate of the bottom right corner of the rectangle of the region in which the film grain rendering is carried out [nY] 6 Bugs Report ═════════════ You can report any bug with the github interface :
In case anyone gets stuck, these worked for me (Ubuntu 18):
sudo apt-get install libtiff-dev
sudo apt-get install libpng-dev
sudo apt-get install freeglut3-dev
I've noticed that in the CUDA implementation of the pixel-wise grain algorithm, the sampling of the input image when iterating through cells is as follows:
// within the iteration of CELLS
float4 src_im_sxsy = tex2D(tex_src_im, (int)max(floor(xGaussian),0.0), (int)max(floor(yGaussian),0.0));
This gets the value of the image at (xGaussian, yGaussian), which is the coordinates of the output pixel, not the input pixel covering the relevant cell.
The CPU implementation seems to be correctly based on (cellCornerX, cellCornerY):
float u = imgIn[ (unsigned int)(fmin(fmax(floor(cellCornerY),0.0),(float)(mIn-1)))*nIn+
(unsigned int)(fmin(fmax(floor(cellCornerX),0.0),(float)(nIn-1)))];
I've read the published article (which has been a fantastic resource) which seems to confirm that the sampling should be at the cell's pixel coordinates:
Hi dear author,
It's a great honor to open one issue here, truly honor. I just begin to learn computer graphics and have compiled your program successfully, but it is hard for me to read the codes, could you please provide some explanation or PPT or papers about the code to me? 👍
thank you
Best Regards with kindness
William
HI dear author,
Honor to write a letter to you, which is my pleasure :)
I have installed the film_grain_rendering_gpu and film_grain_rendering, but I have tested the cuda in film_grain_rendering as well. I want to know what is the difference between film_grain_rendering_gpu and film_grain_rendering, film_grain_rendering also uses GPU.
thank you
best regards
William
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.