Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

please DO NOT WRITE FOR LOOPS like that, ever , with opencv.

  • you can only swap i,j safely IF you image is quadratic
  • j<=input.cols; is out of bounds, same for rows
  • applying log() only makes sense for float data

it should be rewritten as:

Mat input = ...
Mat tmp;
input.convertTo(tmp, CV_32F, 1.0, 1.0);
cv::log(tmp.t(), output);
normalize(output,output,0,255,NORM_MINMAX, CV_8U);

please DO NOT WRITE FOR LOOPS like that, ever , with opencv.

  • you can only swap i,j safely IF you image is quadratic
  • j<=input.cols; is out of bounds, same for rows
  • applying log() only makes sense for float data

it should be rewritten as:

Mat input = ...
Mat tmp;
tmp, output;
input.convertTo(tmp, CV_32F, 1.0, 1.0);
1.0); // to float, also add 1
cv::log(tmp.t(), output);
output);   // log on transposed Mat
normalize(output,output,0,255,NORM_MINMAX, CV_8U);
CV_8U); // back to uchar

please DO NOT WRITE FOR LOOPS like that, ever , with opencv.

  • you can only swap i,j safely IF you your image is quadratic
  • j<=input.cols; is out of bounds, same for rows
  • applying log() only makes sense for float data

it should be rewritten as:

Mat input = ...
Mat tmp, output;
input.convertTo(tmp, CV_32F, 1.0, 1.0); // to float, also add 1
cv::log(tmp.t(), output);   // log on transposed Mat
normalize(output,output,0,255,NORM_MINMAX, CV_8U); // back to uchar