vil_crop.cxx
Go to the documentation of this file.
1 // This is core/vil/vil_crop.cxx
2 //:
3 // \file
4 // \author Ian Scott.
5 //
6 //-----------------------------------------------------------------------------
7 
8 #include "vil_crop.h"
9 #include <cassert>
10 #ifdef _MSC_VER
11 # include <vcl_msvc_warnings.h>
12 #endif
13 #include <vil/vil_exception.h>
14 
15 
17  unsigned n_i, unsigned j0, unsigned n_j)
18 {
19  return new vil_crop_image_resource(src, i0, n_i, j0, n_j);
20 }
21 
22 
24  unsigned i0, unsigned n_i,
25  unsigned j0, unsigned n_j):
26  src_(gi),
27  i0_(i0),
28  ni_(n_i),
29  j0_(j0),
30  nj_(n_j)
31 {
32  assert (i0+n_i <= src_->ni() && j0 + n_j <= src_->nj());
33 }
34 
36  unsigned j0, unsigned n_j) const
37 {
38  if (i0 + n_i > ni() || j0 + n_j > nj())
39  {
41  "vil_crop_image_resource::get_copy_view") );
42  return nullptr;
43  }
44  return src_->get_copy_view(i0+i0_, n_i, j0+j0_, n_j);
45 }
46 
48  unsigned j0, unsigned n_j) const
49 {
50  if (i0 + n_i > ni() || j0 + n_j > nj())
51  {
53  "vil_crop_image_resource::get_view") );
54  return nullptr;
55  }
56  return src_->get_view(i0+i0_, n_i, j0+j0_, n_j);
57 }
vil_crop_image_resource(vil_image_resource_sptr const &, unsigned i0, unsigned n_i, unsigned j0, unsigned n_j)
Definition: vil_crop.cxx:22
Exceptions thrown by vil, and a mechanism for turning them off.
Indicates that some reference was made to pixels beyond the bounds of an image.
Definition: vil_exception.h:81
unsigned ni() const override
Dimensions: Planes x ni x nj.
Definition: vil_crop.h:43
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
void vil_exception_warning(T exception)
Throw an exception indicating a potential problem.
Definition: vil_exception.h:37
vil_image_resource_sptr src_
Definition: vil_crop.h:69
vil_image_view< T > vil_crop(const vil_image_view< T > &im, unsigned i0, unsigned n_i, unsigned j0, unsigned n_j)
Create a view which is a cropped version of src.
Definition: vil_crop.h:21
unsigned nj() const override
Dimensions: Planes x ni x nj.
Definition: vil_crop.h:44
A generic_image adaptor that behaves like a cropped version of its input.
Definition: vil_crop.h:36
vil_image_view_base_sptr get_view() const
Create a read/write view of all the data.