Reputation: 14386
I wish know if EmguCV permits a simple and efficient way to do what in MATLAB is done with the following line:
C = A .* B
(assuming that A, B and C are matrix representing grayscale images with the same dimensions and types).
Assuming that I want to do the same operation above, but using two Image<Gray, byte>
objects of EmguCV, the question is: is there a way to multiply point by point two image with the same dimensions?
Upvotes: 2
Views: 3026
Reputation: 14386
I solved the problem. Assuming that we have three grayscale images, defined in this way:
//We can use, for example, two files with the same dimensions, e.g. 100x100
Image<Gray, byte> A = new Image<Gray, byte>("imgA_100x100.jpg");
Image<Gray, byte> B = new Image<Gray, byte>("imgB_100x100.jpg");
//The image C will be the result of point-by-point multiplication
//We need to initialize it
Image<Gray, byte> C = new Image<Gray, byte>(A.Width, A.Height);
In order to perform the multiplication, you simply need to use the following code:
CvInvoke.cvMul(A.Ptr, B.Ptr, C.Ptr, scale);
The above line perform the multiplication, point by point, with a scale factor that I called scale
. Using a pseudocode to explain what the code above implies, we can say that:
C[i, j] = A[i, j] * B[i, j] * scale
Upvotes: 3