Mat multX = pow(alpha,beta)*srx32.at<float>(i,j*channel+c)*pow(mag.at<float>(i,j*channel+c),-1*beta);
Mat multY = pow(alpha,beta)*sry32.at<float>(i,j*channel+c)*pow(mag.at<float>(i,j*channel+c),-1*beta);

Mat mask = (srx32 != 0);

multX.copyTo(srx32, mask);
multY.copyTo(sry32, mask);