24 #include <fvfilters/difference.h>
26 #include <fvutils/color/yuv.h>
29 namespace firevision {
39 FilterDifference::FilterDifference()
40 :
Filter(
"FilterDifference", 2)
48 if (
src[0] == NULL )
return;
49 if (
src[1] == NULL )
return;
50 if (
src_roi[0] == NULL )
return;
51 if (
src_roi[1] == NULL )
return;
53 register unsigned int h = 0;
54 register unsigned int w = 0;
60 register unsigned char *bup = YUV422_PLANAR_U_PLANE(
src[0],
src_roi[0]->image_width,
src_roi[0]->image_height)
63 register unsigned char *bvp = YUV422_PLANAR_V_PLANE(
src[0],
src_roi[0]->image_width,
src_roi[0]->image_height)
70 register unsigned char *fup = YUV422_PLANAR_U_PLANE(
src[1],
src_roi[1]->image_width,
src_roi[1]->image_height)
73 register unsigned char *fvp = YUV422_PLANAR_V_PLANE(
src[1],
src_roi[1]->image_width,
src_roi[1]->image_height)
87 unsigned char *lbyp = byp;
88 unsigned char *lbup = fup;
89 unsigned char *lbvp = fvp;
90 unsigned char *lfyp = fyp;
91 unsigned char *lfup = fup;
92 unsigned char *lfvp = fvp;
93 unsigned char *ldyp = dyp;
94 unsigned char *ldup = dup;
95 unsigned char *ldvp = dvp;
97 for (h = 0; (h <
src_roi[1]->
height) && (h < dst_roi->height); ++h) {
98 for (w = 0; (w <
src_roi[1]->
width) && (w < dst_roi->width); w += 2) {
99 *dyp++ = ((*byp - *fyp) < 0) ? 0 : (*byp - *fyp);
101 *dyp++ = ((*byp - *fyp) < 0) ? 0 : (*byp - *fyp);
104 *dup++ = (*fup++ + *bup++) / 2;
105 *dvp++ = (*fvp++ + *bvp++) / 2;