50 for(
int yy=0, y=0; y < in.
size().
y-2; y+=3, yy+=2)
51 for(
int xx=0, x=0; x < in.
size().
x-2; x+=3, xx+=2)
57 sum_type b = in[y][x+1]*2;
58 sum_type d = in[y+1][x]*2;
59 sum_type f = in[y+1][x+2]*2;
60 sum_type h = in[y+2][x+1]*2;
61 sum_type e = in[y+1][x+1];
63 out[yy][xx] =
static_cast<C
>((in[ y][ x]*4+b+d+e)/9);
64 out[yy][xx+1] =
static_cast<C
>((in[ y][x+2]*4+b+f+e)/9);
65 out[yy+1][xx] =
static_cast<C
>((in[y+2][ x]*4+h+d+e)/9);
66 out[yy+1][xx+1] =
static_cast<C
>((in[y+2][x+2]*4+h+f+e)/9);
108 const T* top = in.
data();
109 const T* bottom = top + in.
size().
x;
111 int ow = out.
size().
x;
114 while (bottom < end) {
115 for (
int j=0; j<ow; j++) {
116 *p =
static_cast<T
>((sum_type(top[0]) + top[1] + bottom[0] + bottom[1])/4);
151 for( ;octaves > 0; --octaves){
188 double sumSq[c] = {0};
189 const T* p = im.
data();
192 for (
int k=0; k<c; k++) {
199 for (
int k=0; k<c; k++) {
220 template <
class S,
class T>
struct Gradient<S,T,1,2> {
253 void gradient(
const BasicImage<byte>& im, BasicImage<
short[2]>& out);
264 for(
unsigned int i = 0; i < Pixel::Component<T>::count; i++){
273 sample( im, x, y, result);
282 const float* base = im[ly]+lx;
290 result = (float)(x*(y*(e-c+d)-e)+y*(c-a)+a);
303 template <
class T,
class S>
319 double min_x = p0[0], min_y = p0[1];
320 double max_x = min_x, max_y = min_y;
324 min_x += w*across[0];
326 max_x += w*across[0];
332 min_y += w*across[1];
334 max_y += w*across[1];
345 if (min_x >= 0 && min_y >= 0 && max_x < iw-1 && max_y < ih-1)
348 for (
int i=0; i<h; ++i, p+=carriage_return)
349 for (
int j=0; j<w; ++j, p+=across)
350 sample(in,p[0],p[1],out[i][j]);
356 const double x_bound = iw-1;
357 const double y_bound = ih-1;
360 for (
int i=0; i<h; ++i, p+=carriage_return) {
361 for (
int j=0; j<w; ++j, p+=across) {
363 if (0 <= p[0] && 0 <= p[1] && p[0] < x_bound && p[1] < y_bound)
364 sample(in,p[0],p[1],out[i][j]);
366 out[i][j] = defaultValue;
379 offset[0] = in.
size().
x/2;
380 offset[1] = in.
size().
y/2;
384 double w = in.
size().
x-1;
385 double h = in.
size().
y-1;
386 int ow = out.
size().
x;
387 int oh = out.
size().
y;
388 base -= down*(oh/2) + across*(ow/2);
389 for (
int row = 0; row < oh; row++, base+=down) {
391 for (
int col = 0; col < ow; col++, x += across) {
393 if (p[0] >= 0 && p[0] <= w-1 && p[1] >=0 && p[1] <= h-1)
394 sample(in,p[0],p[1], out[row][col]);
405 std::auto_ptr<T> buffer_auto(
new T[w]);
406 T* buffer = buffer_auto.get();
408 T * bottom = top + (in.
size().
y - 1)*w;
409 while( top < bottom )
424 std::auto_ptr<T> buffer_auto(
new T[w]);
425 T* buffer = buffer_auto.get();
426 T * left = in.
data();
427 T * right = left + w;
432 std::reverse_copy(buffer, buffer+w-1, left);
441 template <
class T>
inline T
median3(T a, T b, T c) {
443 return std::max(b,std::min(a,c));
445 return std::max(a,std::min(b,c));
448 template <
class T>
inline void sort3(T& a, T& b, T& c) {
456 T a = p[-w-1], b = p[-w], c = p[-w+1], d=p[-1], e=p[0], f=p[1], g=p[w-1], h=p[w], i=p[w+1];
461 g = std::max(std::max(a,d),g);
462 c = std::min(c,std::min(f,i));
468 T a = p[-w-1], b = p[-w], d=p[-1], e=p[0], g=p[w-1], h=p[w];
471 for (
int j=0; j<n; ++j, ++p, ++out) {
472 T c = p[-w+1], f = p[1], i = p[w+1];
474 *out =
median3(std::min(std::min(g,h),i),
476 std::max(std::max(a,b),c));
477 a=b; b=c; d=e; e=f; g=h; h=i;
486 const int n = I.
size().
x - 2;
487 for (
int i=1; i+1<I.
size().
y; ++i)
498 #endif // CVD_VISION_H_
Pixel::traits< SComp >::wider_type diff_type
int totalsize() const
What is the total number of elements in the image (i.e. size().x * size().y), including padding...
void halfSample(const BasicImage< T > &in, BasicImage< T > &out)
void execute(Image< D > &j)
static const P & get(const P &pixel, size_t)
void resize(const ImageRef &size)
Pixel::Component< S >::type SComp
ImagePromise(const SubImage< C > &im)
void gradient(const BasicImage< S > &im, BasicImage< T > &out)
void median_filter_3x3(const SubImage< T > &I, SubImage< T > out)
static void gradient(const BasicImage< S > &I, BasicImage< T > &grad)
void sort3(T &a, T &b, T &c)
void gradient(const BasicImage< byte > &im, BasicImage< short[2]> &out)
void copy(const BasicImage< S > &in, BasicImage< T > &out, ImageRef size=ImageRef(-1,-1), ImageRef begin=ImageRef(), ImageRef dst=ImageRef())
int row_stride() const
What is the row stride of the image?
S operator()(const S &s) const
Pixel::Component< T >::type TComp
int transform(const BasicImage< S > &in, BasicImage< T > &out, const TooN::Matrix< 2 > &M, const TooN::Vector< 2 > &inOrig, const TooN::Vector< 2 > &outOrig, const T defaultValue=T())
void median_filter_3x3(const T *p, const int w, const int n, T *out)
T median_3x3(const T *p, const int w)
void threshold(BasicImage< T > &im, const T &minimum, const T &hi)
void zeroBorders(BasicImage< T > &I)
Set the one-pixel border (top, bottom, sides) of an image to zero values.
ImageRef size() const
What is the size of this image?
const T * data() const
Returns the raw image data.
void sample(const BasicImage< S > &im, double x, double y, T &result)
void flipVertical(Image< T > &in)
flips an image vertically in place.
void twoThirdsSample(const SubImage< C > &in, SubImage< C > &out)
const_iterator end() const
const_iterator begin() const
void stats(const BasicImage< T > &im, T &mean, T &stddev)
Vector<(Size==Dynamic?Dynamic:Size-1), Precision > project(const Vector< Size, Precision, Base > &v)
void flipHorizontal(Image< T > &in)
flips an image horizontally in place.