Pixel-wise summation and subtraction in EmguCV

僤鯓⒐⒋嵵緔 提交于 2019-12-11 03:23:11

问题


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?

Previous Thread


回答1:


You could probably use img.GetSum() if you first flip the sign of the pixels you want to be subtracted. You might be able to do that by multiplying the image element-wise with a matrix consisting of 1 and -1 at the appropriate places.



来源:https://stackoverflow.com/questions/16476050/pixel-wise-summation-and-subtraction-in-emgucv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!