I'm trying to learn OpenCV and I want to apply this simple formula:
That is a per-pixel operation and transform the pixel from r to s.
This is my code:
int main(int /*argc*/, char** /*argv*/) {
Mat _img = imread("lena.jpg");
cvtColor(_img, img, CV_32F);
cout << "original image size: " << img.rows << " " << img.cols << endl;
cout << "original type: " << img.type() << endl;
cout << "original depth: " << img.depth() << endl;
Mat _src = img.clone();
_src += 1;
log(_src, logContrast);
logContrast *= log_c;
/// ...
And I get this error:
OpenCV Error: Assertion failed (depth == CV_32F || depth == CV_64F) in log, file /home/user/Documents/Code/OpenCV-2.3.1/modules/core/src/mathfuncs.cpp, line 1772
terminate called after throwing an instance of 'cv::Exception'
what(): /home/alberto/Documents/Code/OpenCV-2.3.1/modules/core/src/mathfuncs.cpp:1772: error: (-215) depth == CV_32F || depth == CV_64F in function log
I tried with gray and coloured image, and with cvtColor
with CV_8U
, CV_32F
and C1
, C3
, but I cout always 0 as depth..
I've spent hours on OpenCV manuals and on OpenCV-2.3.1/modules/core/include/opencv2/core/ types_c.h but.. I can't find a solution. I think I've done some confusion on how transform depth of a Mat
object.