Reputation: 3407
Hi I'm using EmguCV and I enjoy programming with it.
However I'm wondering whether there is an elegant way to add two pixels individually.
To add images, you can use CvInvoke.Add(), but for individual pixel operation, you seems to have to write it in an ugly way,
say you have p, p1 and p2 as EmguCV::Bgr,
you have to write
p = new Bgr(p1.b + p2.b, p1.g + p2.g, p1.r + p2.r);
I really hate this and tried to write an operator for this. But this is apparently impossible since operator overloading must be in the host class.
Is there any way to do this elegantly?
================Edit================
What I want to do is to calculate the summation of the pixels in an image. So the basic operation in this is to add pixels, or Bgr class.
Upvotes: 0
Views: 1007
Reputation: 2702
Let's suppose you have two images img1
and img2
:
img3
= img1+ img2
If you simply want the summation of each color channel on a single image img1
you can do:
Bgr sums = img1.GetSum();
double TotalVal = sums.Blue + sums.Green + sums.Red;
Hope this helps,
Luca
Upvotes: 1