pfstmo_fattal02(1)

✨ pfstmo_fattal02 β€” the gradient domain glow-up ✨

okay bestie, gather round, because this is pfstmo_fattal02(1) from the General Commands Manual and she is iconic πŸ’…


🌸 NAME 🌸

pfstmo_fattal02 β€” Gradient domain high dynamic range compression πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

pfstmo_fattal02 [--alpha <val>] [--beta <val>] [--gamma <val>]
[--saturation <val>] [--noise <val>] [--detail-level <val>] [--black-
point <val>] [--white-point <val>] [--multigrid] [--verbose] [--help]

πŸ’– DESCRIPTION πŸ’–

So this command implements a tone mapping operator, exactly as described in:

Gradient Domain High Dynamic Range Compression β€” R. Fattal, D. Lischinski, and M. Werman, In ACM Transactions on Graphics, 31(3), p. 249, 2002.

Compared to the original paper, this program has an extra parameter that limits the amplification of noise 🫢. The noise often gets starkly amplified because of a division by zero in one of the equations in the paper β€” not me saying that, that's literally the situation 😭. This extension was contributed by Przemyslaw Bazarnik.

At the core of the programme is a Poisson PDE, which β€” as suggested in the original paper β€” is solved using a Full Multigrid Algorithm. But plot twist πŸ™ˆ: this is an iterative solver, and it seems to lose accuracy when you throw higher resolution images at it, which results in halo effects and surreal looking images. For that reason a second solver has been implemented, using the discrete cosine transform as the underlying method, and it's considerably more accurate β€” mainly because it's a direct solver. This solver is the preferred method and is used by default πŸ‘‘. The old multigrid solver can be selected with the --multigrid (-m) option.


πŸ’… OPTIONS πŸ’…

  • --alpha <val>, -a <val> β€” Set alpha parameter. This parameter is depreciated, because setting a <val> other than 1.0 has only the effect of a global gamma adjustment of the luminance channel, which can be directly specified using the --gamma option. See the paper for the definition of alpha. It can be shown β€” although it's not mentioned in the paper β€” that setting alpha other than 1.0 has the same effect as setting gamma = alpha^(k*(1-beta)), where beta is the value as specified by --beta and k is the number of levels of the Gaussian Pyramid (see paper for details), which depends on the image pixel size (smallest k so that 2^(k+detail_level) >= min(width,height)/MSIZE, MSIZE see source code, e.g. 8 or 32).
  • --beta <val>, -b <val> β€” Set beta parameter. <val> sets the strength of gradient (local contrast) modification. Suggested range is 0.8 to 0.96, default is 0.9 (see paper for details). Value of 1 does not change contrasts, values above 1 reverse the effect: local contrast is stretched and details are attenuated. Values below 0.5 lead to very strong amplification of small contrast, so consider using the --noise parameter to prevent noise 🫠.
  • --gamma <val>, -g <val> β€” Set luminance gamma adjustment. This can be described as a global contrast enhancement, and it's applied after the local enhancement as specified by the parameter --beta is performed. Gamma adjustment or correction is defined by a power-law, in this case L_out(x,y) = L_in(x,y)^gamma, where L_in(x,y)=exp(I(x,y)) is the luminance value after the local contrast enhancement (I is the solution of the Poisson PDE). The suggested range for <val> is 0.6 to 1.0, default is 0.8 ✨.
  • --saturation <val>, -s <val> β€” Amount of color saturation. Suggested range is 0.4 to 0.8. Default value: 0.8.
  • --noise <val>, -n <val> β€” Reduces the gradient amplification value for gradients close to 0 and reduces noise as a result. <val> defines gradient value (luminance difference of adjacent pixels) which is treated as noise. Suggested range is 0.0 to the value of alpha. Default value calculated based on alpha: 0.001*alpha.
  • --detail-level <val>, -d <val> β€” Specifies up to which detail level the local contrast enhancement should be performed. It basically means that local contrast levels within small squares of pixel size 2^<val> are not changed. In the implementation this corresponds to removing the <val> finest levels of the Gaussian Pyramid as described in the paper, i.e. the paper only considers <val>=0. Suggested values are 1, 2 or 3; 3 for high resolution images. The default is 3 for --fftsolver, and 0 if the original multi-level solver is used (to be consistent with the paper).
  • --white-point <val>, -w <val> β€” Specifies the percentage of pixels which are allowed to be overexposed and therefore blown out. This can be useful for example when there is a very bright object in the image like the sun β˜€οΈ and details of it do not need to be resolved. As a result the overall image will look brighter the greater <val> is. Default is 0.5.
  • --black-point <val>, -k <val> β€” Same as --white-point but for under-exposed pixels. Default is 0.1.
  • --multigrid, -m β€” Enable the use of the multigrid solver as suggested by the original paper. For accuracy the default fft solver is generally recommended, especially when using high resolution images. The user will benefit by obtaining photo-realistic rather than surreal looking images. The fft solver is also faster despite the fact it is only O(n*log n) with n=width*height, as compared to O(n) for the multigrid solver. The speed improvement is thanks to the very efficient fftw3 library which is used to calculate the discrete cosine transform πŸ”₯.
  • --verbose β€” Print additional information during program execution.
  • --help β€” Print list of command line options.

🌈 EXAMPLES 🌈

pfsin memorial.hdr | pfstmo_fattal02 -v -t | pfsout memorial.png

Tone map image (using fft solver) and save it in png format.

pfsin memorial.hdr | pfstmo_fattal02 -v -t -b 0.85 -g 0.7 -w 2.0 \
       | pfsout memorial.png

Tone map image (using fft solver) with stronger contrast modification than default, i.e. beta=0.85, gamma=0.7 and white point 2.0%.

pfsin memorial.hdr | pfstmo_fattal02 -v | pfsout memorial.png

Tone map image (old style) and save it in png format.


πŸ‘‘ SEE ALSO πŸ‘‘

pfsin(1) pfsout(1) pfsview(1)


⭐ KNOWN ISSUES ⭐

For stronger local contrast enhancements (beta<0.9) the fft solver (--fftsolver) might produce slightly dark image corners 😭. This can be mitigated using bigger values for the --noise parameter.

With a value of --detail-level greater than 0, the internal implementation could be made much more efficient as only a reduced sized PDE would need to be solved, greatly improving speed.


πŸ’€ BUGS πŸ’€

Please report bugs and comments on implementation to the pfstools discussion group (http://groups.google.com/group/pfstools). For bugs specific to the FFT solver email Tino Kluge <tino.kluge@hrz.tu-chemnitz.de>.


and that's the whole page, bestie β€” pfstmo_fattal02(1), straight out of the General Commands Manual, no cap. go forth and tone map, you absolute main character πŸ«ΆπŸ’–