gabrieleilertsen / hdrcnn

HDR image reconstruction from a single exposure using deep CNNs
https://computergraphics.on.liu.se/hdrcnn/
BSD 3-Clause "New" or "Revised" License
502 stars 101 forks source link

Question about the smoothness metric #51

Closed AnjieCheng closed 2 years ago

AnjieCheng commented 2 years ago

Hi, thanks for sharing this awesome work!

I'm interested in the smoothness metric mentioned in your CVPR'19 paper. If you don't mind, could you share the implementation details or short code snippets for Eq. 9?

Thank you!

gabrieleilertsen commented 2 years ago

Hi. This is a Matlab-implementation of the smoothness metric:

function S = video_smoothness( test_vid, ref_vid, fps )
  if nargin < 3
      fps = 30;
  end

  freq_cutoff = 0.15; % [s] - this should remove less visible temporal frequencies
  sigma = fps*freq_cutoff;

  test_hp = get_hp(test_vid);
  ref_hp = get_hp(ref_vid);

  S = mean( ref_hp(:) ) / mean( test_hp(:) );

  function vid_hp = get_hp( vid )        

      k_size = round(ceil( sigma*5 )/2)*2;
      xx = linspace( -k_size/2, k_size/2, k_size+1 );
      gauss_kernel = exp( -xx.^2 / (2*sigma^2) );
      gauss_kernel = gauss_kernel/sum(gauss_kernel);

      vid_lp = filtfilt( gauss_kernel, 1, vid );

      vid_hp = sqrt(mean((vid - vid_lp).^2,1));

  end
end
AnjieCheng commented 2 years ago

Thank you! That helps a lot.