hor_search.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <filters/hor_search.h>
00026
00027 #include <fvutils/color/yuv.h>
00028
00029 #include <cstddef>
00030 #include <cstring>
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 FilterHSearch::FilterHSearch(ColorModel *cm, color_t what)
00045 : Filter("FilterHSearch")
00046 {
00047 this->cm = cm;
00048 this->what = what;
00049 }
00050
00051
00052 void
00053 FilterHSearch::apply()
00054 {
00055 register unsigned int h = 0;
00056 register unsigned int w = 0;
00057
00058
00059 register unsigned char *yp = src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step);
00060
00061 register unsigned char *up = YUV422_PLANAR_U_PLANE(src[0], src_roi[0]->image_width, src_roi[0]->image_height)
00062 + ((src_roi[0]->start.y * src_roi[0]->line_step) / 2 + (src_roi[0]->start.x * src_roi[0]->pixel_step) / 2) ;
00063
00064 register unsigned char *vp = YUV422_PLANAR_V_PLANE(src[0], src_roi[0]->image_width, src_roi[0]->image_height)
00065 + ((src_roi[0]->start.y * src_roi[0]->line_step) / 2 + (src_roi[0]->start.x * src_roi[0]->pixel_step) / 2);
00066
00067
00068 register unsigned char *dyp = dst + (dst_roi->start.y * dst_roi->line_step) + (dst_roi->start.x * dst_roi->pixel_step);
00069
00070
00071 unsigned char *lyp = yp;
00072 unsigned char *lup = up;
00073 unsigned char *lvp = vp;
00074 unsigned char *ldyp = dyp;
00075
00076
00077 unsigned int left;
00078 unsigned int right;
00079 bool flag;
00080
00081 for (h = 0; (h < src_roi[0]->height) && (h < dst_roi->height); ++h) {
00082 flag = false;
00083 left = right = 0;
00084 for (w = 0; (w < src_roi[0]->width) && (w < dst_roi->width); ++w) {
00085 if ( (cm->determine(*yp++, *up, *vp) == what) ) {
00086 right = w;
00087 flag = true;
00088 } else {
00089 left = flag?left:w;
00090 }
00091 if ( (cm->determine(*yp++, *up++, *vp++) == what) ) {
00092 right = ++w;
00093 flag = true;
00094 } else {
00095 ++w;
00096 left = flag?left:w;
00097 }
00098 }
00099
00100
00101 memset(ldyp, 0, dst_roi->width);
00102
00103
00104
00105
00106 if (left != 0 && left < dst_roi->width) ldyp[left] = 255;
00107 if (right != 0 && right < dst_roi->width) ldyp[right] = 255;
00108
00109 lyp += src_roi[0]->line_step;
00110 lup += src_roi[0]->line_step / 2;
00111 lvp += src_roi[0]->line_step / 2;
00112 ldyp += dst_roi->line_step;
00113 yp = lyp;
00114 up = lup;
00115 vp = lvp;
00116 dyp = ldyp;
00117 }
00118
00119 }
00120