I'm looking for an elegant way to perform pixel-wise summation and subtraction in EmguCV.
I'm trying to calculate the Haar-like features of an image. For a one-dimensional situation, it's done by multiplying the vector [x x x x x x x x] by the following vector element-wise:
[ 1 -1 1 -1 1 -1 1 -1]
[ 1 1 -1 -1 1 1 -1 -1]
[ 1 1 1 1 -1 -1 -1 -1]
So I need to add or subtract the element pixels of an image.
Say,
Bgr sum = new Bgr();
sum = sum + img[0,0] - img[0,1] + img[0,2] - img[0,3];
Obviously this won't compile since there's no operator "+" in class Bgr. I've to make a new Bgr by specifying each of the B, G, R value, which is ugly.
Any idea on performing elegant pixel-wise operation?