1 #ifndef vil_find_4con_boundary_h_ 2 #define vil_find_4con_boundary_h_ 8 # include <vcl_msvc_warnings.h> 23 std::ptrdiff_t istep,std::ptrdiff_t jstep,
31 if (i<ni1 && p[istep]<=threshold) { ++i; p+=istep; dir=3;
return; }
33 if (j<nj1 && p[jstep]<=threshold) { ++j; p+=jstep; dir=0;
return; }
35 if (i>0 && p[-istep]<=threshold) { --i; p-=istep; dir=1;
return; }
37 if (j>0 && p[-jstep]<=threshold) { --j; p-=jstep; dir=2;
return; }
50 int ni1,
int nj1, std::ptrdiff_t istep, std::ptrdiff_t jstep,
58 if (i<ni1 && p[istep]>=threshold) { ++i; p+=istep; dir=3;
return; }
60 if (j<nj1 && p[jstep]>=threshold) { ++j; p+=jstep; dir=0;
return; }
62 if (i>0 && p[-istep]>=threshold) { --i; p-=istep; dir=1;
return; }
64 if (j>0 && p[-jstep]>=threshold) { --j; p-=jstep; dir=2;
return; }
85 bi.resize(0); bj.resize(0);
86 int ni1 = image.
ni()-1;
87 int nj1 = image.
nj()-1;
88 std::ptrdiff_t istep = image.
istep(), jstep=image.
jstep();
90 int i = p0_i, j = p0_j;
91 const T* p = &image(i,j);
92 assert(*p<=threshold);
95 while (i<ni1 && p[istep]<=threshold) {i++;p+=istep;}
101 while (j<nj1 && p[jstep]<=threshold) {j++;p+=jstep;}
109 bi.push_back(i); bj.push_back(j);
112 while (i!=i0 || j!=j0);
123 std::vector<int>& bj,
128 bi.resize(0); bj.resize(0);
129 int ni1 = image.
ni()-1;
130 int nj1 = image.
nj()-1;
131 std::ptrdiff_t istep = image.
istep(), jstep=image.
jstep();
133 int i = p0_i, j = p0_j;
134 const T* p = &image(i,j);
135 assert(*p>=threshold);
138 while (i<ni1 && p[istep]>=threshold) {i++;p+=istep;}
144 while (j<nj1 && p[jstep]>=threshold) {j++;p+=jstep;}
152 bi.push_back(i); bj.push_back(j);
155 while (i!=i0 || j!=j0);
158 #endif // vil_find_4con_boundary_h_ Concrete view of image data of type T held in memory.
void vil_next_point_below_thresh4(int &i, int &j, int &dir, const T *&p, int ni1, int nj1, std::ptrdiff_t istep, std::ptrdiff_t jstep, T threshold)
Move (i,j) to next point below threshold.
void vil_find_4con_boundary_below_threshold(std::vector< int > &bi, std::vector< int > &bj, const vil_image_view< T > &image, const T &threshold, int p0_i, int p0_j)
Find 4-connected boundary around thresholded region containing point.
std::ptrdiff_t jstep() const
Add this to your pixel pointer to get next j pixel.
unsigned ni() const
Width.
unsigned nj() const
Height.
void vil_next_point_above_thresh4(int &i, int &j, int &dir, const T *&p, int ni1, int nj1, std::ptrdiff_t istep, std::ptrdiff_t jstep, T threshold)
Move (i,j) to next point above threshold.
void vil_find_4con_boundary_above_threshold(std::vector< int > &bi, std::vector< int > &bj, const vil_image_view< T > &image, const T &threshold, int p0_i, int p0_j)
Find 4-connected boundary around thresholded region containing point.
A base class reference-counting view of some image data.
std::ptrdiff_t istep() const
Add this to your pixel pointer to get next i pixel.