What algorithm does calcBackProject implement?

I was studying the source of calcBackProject and couldn’t figure out whether the implementation follows the original histogram backprojection algorithm proposed by Michael J. Swain, Dana H. Ballard in their paper Indexing via color histograms.

A brief introduction of this algorithm is given by the official tutorial Histogram Backprojection- Algorithm in Numpy:

  1. Calculate the histogram of the target image I and that of the model image M.
  2. Find their ratio histogram R = M/I.
  3. Backproject R, i.e. for an intensity level L maps it to its corresponding height in R.

However in another OpenCV tutorial Back Projection it seems to suggest that the backprojection uses only M:

  1. Calculate the model image histogram M.
  2. Backproject M.

I went through the source of calcBackProject https://github.com/opencv/opencv/blob/master/modules/imgproc/src/histogram.cpp#L1609(sorry I’m only allowed two links in my first post) but could find out where R is calculated. Could anyone let me know which algorithm calcBackProject actually implements?

Many thanks.