1 | initial version |
since the adjunct of a matrix is it's determinant, multiplied by the inverse, -- we can just write it like that !
taking the wikipedia example :
Mat_<float> A(3,3);
A << -3,2,-5,
-1,0,-2,
3,-4,1;
Mat A_adj = determinant(A) * A.inv();
cout << A_adj << endl;
output:
[-8, 18, -4;
-5, 12, -1;
4, -6, 2]
2 | No.2 Revision |
since the adjunct of a matrix is it's determinant, multiplied by the inverse, -- we can just write it like that !
taking the wikipedia example :
Mat_<float> A(3,3);
A << -3,2,-5,
-1,0,-2,
3,-4,1;
Mat A_adj = determinant(A) * A.inv();
cout << A_adj << endl;
output:
[-8, 18, -4;
-5, 12, -1;
4, -6, 2]
if you want to use a grayscale image here, you'll have to convert it to float first:
Mat im = ...
Mat fimg;
img.convertTo(fimg, CV_32F);