I’m developing an Active Contour Algorithm in OpenCV, in one of the steps I need to take the negative of the gradient -V[I(x,y)] … How can I perform this operation, I have tried this:
//load image (type CV_32FC3) and calculate gradient
neg = cv::Mat(gradient.cols,gradient.rows,CV_32FC3,cv::Scalar::all(-1));
gradient.mul(neg,1);
//to verify negatives value
double minVal, maxVal;
int maxIdx[3];
cv::minMaxIdx(gradient.reshape(1,0),&minVal,&maxVal,0,maxIdx);
std::cout << maxVal << " , " << minVal << std::endl;
But I only get values in the range of 10^-38 when I print it.
Thank you.
Do opencv::mul(gradient,neg,gradient,1) give the same?
But it might be that you need to gradient = gradient.mul(neg). I dont have opencv installed so cant check.