Working with the log() function

In a simple program:

int main(int argc, char** argv)
{
  Mat img = imread("img.jpg", IMREAD_UNCHANGED);
  if (img.empty())
  {
    cout << "Image file not found!" << endl;
    system("pause");
    exit(1);
  }
  Mat result = img.clone();
  try
  {
    log(img, result);
  }
  catch (exception& e)
  {
    e.what();
    system("pause");
    exit(1);
  }
  imwrite("log.jpg", result);
  system("pause");
  exit(0);
}

an error appears: “OpenCV(4.5.5) Error: Assertion failed (depth == CV_32F || depth == CV_64F) in cv::log, file C:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\mathfuncs.cpp, line 702”. As I understand from the documentation, the only requirement for this function is the equivalence of the source and result expressions by type and size. That’s what I used cloning for. Why does the error also specify requirements for the image type (depth == CV_32F || depth == CV_64F)? Please help me. Project OpenCVquestions2.zip — Яндекс.Диск

use convertTo to convert type. then log will be happy.

don’t assume the docs to be a specification. they’re docs. don’t assume the implementation to be arbitrarily flexible. it has practical limits. and this function’s limits seem to be the data type. apparently nobody so far needed logarithms on integers, so it’s simply not implemented.