c++ - using pow in opencv to raise every array element to a power generate error -


i trying write function change gamma of input image.

the code wrote follow:

if(inputimage.channels() >= 3) {    mat hsv;      cvtcolor(inputimage,hsv,cv_bgr2hsv_full);      vector<mat> channels;     split(hsv,channels);      mat tmp1=(channels[2]/255);     mat tmp;     pow(tmp1,1.5,tmp);     channels[2]=255 *tmp;     mat result;     merge(channels,hsv);      cvtcolor(hsv,result,cv_hsv2bgr_full);      return result; } 

but getting run timeerror on line pwo(...): error is:

opencv error: assertion failed (depth == cv_32f || depth == cv_64f) in unknown function, file c:\slave\builds\wininstallermegapack\src\opencv\modules\core\src\mathfuncs.cpp, line 1931 

if change 1.5 2 in pow, there no error. how can raise each element of matrix in opencv non integer value?

is there better way change gamma of image in opencv?

as error implies, input image tmp1 should in cv_32f or cv_64f format. example, can write:

mat newtmp1; tmp1.convertto(newtmp1, cv_32f); pow(newtmp1,1.5,tmp); 

so pow function can operate on 32 bit float matrix newtmp1.


Comments