16 # include <vcl_msvc_warnings.h> 22 static const unsigned long large_image_limit = 1024ul * 1024ul * 8ul;
33 unsigned i_factor,
unsigned j_factor):
38 assert (i_factor > 0 && j_factor > 0);
43 unsigned j0,
unsigned nj)
const 46 (
unsigned long)
j_factor_ * (
unsigned long)
nj < large_image_limit)
50 if (!vs)
return nullptr;
59 "vil_decimate_image_resource::get_copy_view") );
63 switch (
src_->pixel_format())
65 #define macro( F , T ) \ 67 vil_image_view<T > view(ni,nj,src_->nplanes()); \ 68 for (unsigned j = 0; j < nj; ++j) \ 69 for (unsigned i = 0; i < ni; ++i) { \ 70 vil_image_view<T > pixel=src_->get_view((i+i0)*i_factor_,1,(j+j0)*j_factor_,1); \ 71 assert ((bool)pixel); \ 72 vil_copy_to_window(pixel, view, i, j); } \ 73 return new vil_image_view<T >(view); } 78 macro(VIL_PIXEL_FORMAT_UINT_64 , vxl_uint_64 )
79 macro(VIL_PIXEL_FORMAT_INT_64 , vxl_int_64 )
93 src_->pixel_format(),
"vil_decimate_image_resource::get_copy_view") );
100 unsigned j0,
unsigned nj)
const 103 (
unsigned long)
j_factor_ * (
unsigned long)
nj < large_image_limit)
107 if (!vs)
return nullptr;
118 if (j_factor==0) j_factor=i_factor;
119 switch (im->pixel_format())
121 #define macro( F , T ) \ 123 return new vil_image_view<T >(vil_decimate(static_cast<vil_image_view<T >&>(*im), \ 124 i_factor, j_factor)); 129 macro(VIL_PIXEL_FORMAT_UINT_64 , vxl_uint_64 )
130 macro(VIL_PIXEL_FORMAT_INT_64 , vxl_int_64 )
144 im->pixel_format(),
"vil_decimate") );
154 "vil_decimate_image_resource::put_view") );
157 #else // disable put_view, because current implementation 165 if ((
unsigned long)
i_factor_ * (
unsigned long)im.
ni() *
166 (
unsigned long)
j_factor_ * (
unsigned long)im.
nj() < large_image_limit)
174 switch (vs->pixel_format())
176 #define macro( F , T ) \ 178 const vil_image_view<T > view = static_cast<const vil_image_view<T >&>(im); \ 179 vil_image_view<T > decimated = \ 180 vil_decimate(static_cast<vil_image_view<T >&>(*vs), i_factor_, j_factor_); \ 181 if (view == decimated) return true; \ 182 assert(view.ni() == decimated.ni() && view.nj() == decimated.nj()); \ 183 vil_copy_reformat(view, decimated); \ 184 return src_->put_view(*vs, i0, j0); } 189 macro(VIL_PIXEL_FORMAT_UINT_64 , vxl_uint_64 )
190 macro(VIL_PIXEL_FORMAT_INT_64 , vxl_int_64 )
210 switch (
src_->pixel_format())
212 #define macro( F , T ) \ 214 const vil_image_view<T > &view = static_cast<const vil_image_view<T > &>(im); \ 215 for (unsigned j = 0; j < im.nj(); ++j) \ 216 for (unsigned i = 0; i < im.ni(); ++i) { \ 217 vil_image_view<T > pixel=vil_crop(view,i,1,j,1); \ 218 assert ((bool)pixel); \ 219 if (!src_->put_view(pixel, (i0+i)*i_factor_, (j0+j)*j_factor_)) \ 226 macro(VIL_PIXEL_FORMAT_UINT_64 ,vxl_uint_64 )
227 macro(VIL_PIXEL_FORMAT_INT_64 , vxl_int_64 )
An abstract base class of smart pointers to actual image data in memory.
Indicates that some operation is not supported.
unsigned nj() const override
Dimensions: Planes x ni x nj.
Exceptions thrown by vil, and a mechanism for turning them off.
unsigned ni() const
Width.
unsigned nj() const
Height.
virtual enum vil_pixel_format pixel_format() const =0
Return a description of the concrete data pixel type.
Indicates that some reference was made to pixels beyond the bounds of an image.
bool put_view(const vil_image_view_base &im, unsigned i0, unsigned j0) override
Put the data in this view back into the image source.
Various image copying functions.
vil_image_resource_sptr vil_decimate(const vil_image_resource_sptr &src, unsigned i_factor, unsigned j_factor=0)
decimate to a region of src.
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
A generic_image adaptor that behaves like a decimated version of its input.
unsigned nplanes() const
Number of planes.
void vil_exception_warning(T exception)
Throw an exception indicating a potential problem.
vil_decimate_image_resource(vil_image_resource_sptr const &, unsigned i_factor, unsigned j_factor)
vil_image_view< T > vil_decimate(const vil_image_view< T > &im, unsigned i_factor, unsigned j_factor=0)
Create a view which is a decimated version of src.
unsigned ni() const override
Dimensions: Planes x ni x nj.
vil_image_resource_sptr src_
vil_image_view_base_sptr get_view() const
Create a read/write view of all the data.