My code for calculate the log of all pixels in an image:
int main(int argc, char** argv)
{
//ABRE A IMAGEM->CINZA e MOSTRA
Mat img = imread("img.jpg", IMREAD_GRAYSCALE);
Mat dest;
cv::log(img, dest);
namedWindow("Histograma");
imshow("Histograma", dest);
if (waitKey(0) == 27) destroyAllWindows();
return 0;
}