Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Apply function to each Mat element

Does anyone know of a more efficient OpenCV practice to perform the following operation on each Mat element ? Each element undergoes the same function.

Mat calcDepthValues(Mat &depth){

Mat realDepth= depth.clone();

Mat_<double>::iterator it = realDepth.begin<double>();
Mat_<double>::iterator itend = realDepth.end<double>();

for (; it != itend; ++it) {

    (*it) = 448.251214 +  ((1- (*it)/255)  * 10758.02914);

return realDepthValues;