Reputation: 20264
Is there per-element inverse opencv function for cv::Mat
?
Example:
|a , b , c|
|d , e , f|
|g , h , i|
Output:
|1/a , 1/b , 1/c|
|1/d , 1/e , 1/f|
|1/g , 1/h , 1/i|
Upvotes: 4
Views: 1124
Reputation: 50667
That will simply be 1.0f / mat
.
Example:
cv::Mat mat = (cv::Mat_<float>(3, 3) << 1, 2, 3,
4, 5, 6,
7, 8, 9);
mat = 1.0f / mat;
Afterwards, mat
will be
[1, 0.5, 0.33333334;
0.25, 0.2, 0.16666667;
0.14285715, 0.125, 0.11111111]
Upvotes: 4