1 | initial version |
I suppose that align is vector of uchar. You have to use substract instead of - to set result type (here float with one channel CV_32FC1):
vector<uchar> align={1,2,3,4};
Mat dev1;
subtract(Mat(align), 2, dev1, Mat(), CV_32FC1);
cout << dev1;
cout << Mat(align)-2;
2 | No.2 Revision |
I suppose that align is vector of uchar. You have to use substract instead of - to set result type (here float with one channel CV_32FC1):
vector<uchar> align={1,2,3,4};
Mat dev1;
subtract(Mat(align), 2, dev1, Mat(), CV_32FC1);
cout << dev1;
cout << Mat(align)-2;
Mat(align)-2; // wrong because uchar cannot be negative
3 | No.3 Revision |
I suppose that align is vector of uchar. You have to use substract instead of - to set result type (here float with one channel CV_32FC1):
vector<uchar> align={1,2,3,4};
Mat dev1;
subtract(Mat(align), 2, dev1, Mat(), CV_32FC1);
cout << dev1;
cout << Mat(align)-2; // wrong because uchar cannot be negative
but @berak solution is better :
you should use meanStdDev()
Mat mean, dev; //you can use Scalar, too.
meanStdDev(image, mean, dev);
PS I will transfer upvote
4 | No.4 Revision |
I suppose that align is vector of uchar. You have to use substract instead of - to set result type (here float with one channel CV_32FC1):
vector<uchar> align={1,2,3,4};
Mat dev1;
subtract(Mat(align), 2, dev1, Mat(), CV_32FC1);
cout << dev1;
cout << Mat(align)-2; // wrong because uchar cannot be negative
but @berak solution is better :
you should use meanStdDev()
Mat mean, dev; //you can use Scalar, too.
meanStdDev(image, mean, dev);
PS I will transfer upvote
5 | No.5 Revision |
I suppose that align is vector of uchar. You have to use substract instead of - to set result type (here float with one channel CV_32FC1):
vector<uchar> align={1,2,3,4};
align={1,1,3,3};
Mat dev1;
subtract(Mat(align), 2, dev1, Mat(), CV_32FC1);
cout << dev1;
cout << Mat(align)-2; // wrong because uchar cannot be negative