This is more readable:
                    if(abs(sgx.at<Vec3f>(i,j) - sgy.at<Vec3f>(i,j)) > abs(grx.at<Vec3f>(i,j) - gry.at<Vec3f>(i,j)))
                    {
                        srx32.at<Vec3f>(i,j) = sgx.at<Vec3f>(i,j) * smask.at<float>(i,j);
                        sry32.at<Vec3f>(i,j) = sgy.at<Vec3f>(i,j) * smask.at<float>(i,j);
                    }
                    else
                    {
                        srx32.at<Vec3f>(i,j) = grx.at<Vec3f>(i,j) * smask.at<float>(i,j);
                        sry32.at<Vec3f>(i,j) = gry.at<Vec3f>(i,j) * smask.at<float>(i,j);
                    }
                }