Mat.forEach for 2 Matrices? Compare elements

asked 2019-10-04 02:31:10 -0500

Hey there,

i successful implemented Mat.forEach for efficient computing values of one Matrix. However for my next step i need to compare each value of 2 matrixes and compute the difference in percent. The most efficient way to iterate over each element of a Matrix is using forEach. Is there a possible way to compare each elements of 2 matrixes using forEach?

edit retag flag offensive close merge delete

Comments

1

i need to compare each value of 2 matrixes

please be more concise. what's the purpose of it ?

The most efficient way to iterate

you should avoid iterating at all cost, and prefer builtin vectorized functions like compare() instead.

again this is somewhat an XY problem. the solution Y you ask about is most likely not the correct answer to problem X, but we need to know the problem to answer.

berak gravatar imageberak ( 2019-10-04 03:02:08 -0500 )edit
1

which language are you talking about, even ?

berak gravatar imageberak ( 2019-10-04 03:04:19 -0500 )edit
1

thanks for your reply.

I need to compute the difference of brightness of each frame in percent. My brightness is a 1 Channel Mat. I use c++ because i need real time observation.

I know that iterating should be avoided. Because of that i want to use .forEach Method for maximum speed because it also uses multithreading. However i dont see how i can implement the per value comparison of 2 Mat with .forEach

MarcelWeigle gravatar imageMarcelWeigle ( 2019-10-04 06:12:59 -0500 )edit
1

difference of brightness

absdiff() and sum()

difference in percent

in percent of what ?

berak gravatar imageberak ( 2019-10-04 06:16:13 -0500 )edit
1

in percent to the first recorded frame

MarcelWeigle gravatar imageMarcelWeigle ( 2019-10-04 06:41:03 -0500 )edit