vil_transpose.cxx
Go to the documentation of this file.
1 // This is core/vil/vil_transpose.cxx
2 //:
3 // \file
4 // \author Ian Scott.
5 //
6 // \verbatim
7 // Modifications
8 // 23 Oct.2003 - Peter Vanroose - Added support for 64-bit int pixels
9 // \endverbatim
10 //
11 //-----------------------------------------------------------------------------
12 
13 #include "vil_transpose.h"
14 
16 {
17  return new vil_transpose_image_resource(src);
18 }
19 
21  src_(src)
22 {
23 }
24 
26  unsigned j0, unsigned nj) const
27 {
28  vil_image_view_base_sptr vs = src_->get_copy_view(j0, nj, i0, ni);
29  if (!vs) return nullptr;
30 
31  switch (vs->pixel_format())
32  {
33 #define macro( F, T ) \
34  case F : \
35  return new vil_image_view<T > (vil_transpose(static_cast<const vil_image_view<T >&>(*vs)));
36 
37  macro(VIL_PIXEL_FORMAT_BYTE, vxl_byte)
38  macro(VIL_PIXEL_FORMAT_SBYTE, vxl_sbyte)
39 #if VXL_HAS_INT_64
40  macro(VIL_PIXEL_FORMAT_UINT_64, vxl_uint_64)
41  macro(VIL_PIXEL_FORMAT_INT_64, vxl_int_64)
42 #endif
43  macro(VIL_PIXEL_FORMAT_UINT_32, vxl_uint_32)
44  macro(VIL_PIXEL_FORMAT_INT_32, vxl_int_32)
45  macro(VIL_PIXEL_FORMAT_UINT_16, vxl_uint_16)
46  macro(VIL_PIXEL_FORMAT_INT_16, vxl_int_16)
49  macro(VIL_PIXEL_FORMAT_COMPLEX_FLOAT , std::complex<float>)
50  macro(VIL_PIXEL_FORMAT_COMPLEX_DOUBLE , std::complex<double>)
51 #undef macro
52  default:
53  return nullptr;
54  }
55 }
56 
58  unsigned j0, unsigned nj) const
59 {
60  vil_image_view_base_sptr vs = src_->get_view(j0, nj, i0, ni);
61  if (!vs) return nullptr;
62 
63  switch (vs->pixel_format())
64  {
65 #define macro( F, T ) \
66  case F : \
67  return new vil_image_view<T > (vil_transpose(static_cast<const vil_image_view<T >&>(*vs)));
68 
69  macro(VIL_PIXEL_FORMAT_BYTE, vxl_byte)
70  macro(VIL_PIXEL_FORMAT_SBYTE, vxl_sbyte)
71 #if VXL_HAS_INT_64
72  macro(VIL_PIXEL_FORMAT_UINT_64, vxl_uint_64)
73  macro(VIL_PIXEL_FORMAT_INT_64, vxl_int_64)
74 #endif
75  macro(VIL_PIXEL_FORMAT_UINT_32, vxl_uint_32)
76  macro(VIL_PIXEL_FORMAT_INT_32, vxl_int_32)
77  macro(VIL_PIXEL_FORMAT_UINT_16, vxl_uint_16)
78  macro(VIL_PIXEL_FORMAT_INT_16, vxl_int_16)
81  macro(VIL_PIXEL_FORMAT_COMPLEX_FLOAT , std::complex<float>)
82  macro(VIL_PIXEL_FORMAT_COMPLEX_DOUBLE , std::complex<double>)
83 #undef macro
84  default:
85  return nullptr;
86  }
87 }
88 
89 //: Put the data in this view back into the image source.
91  unsigned j0)
92 {
93  switch (im.pixel_format())
94  {
95 #define macro( F, T ) \
96  case F : \
97  return src_->put_view(vil_transpose(static_cast<const vil_image_view<T >&>(im)), j0, i0);
98 
99  macro(VIL_PIXEL_FORMAT_BYTE, vxl_byte)
100  macro(VIL_PIXEL_FORMAT_SBYTE, vxl_sbyte)
101 #if VXL_HAS_INT_64
102  macro(VIL_PIXEL_FORMAT_UINT_64, vxl_uint_64)
103  macro(VIL_PIXEL_FORMAT_INT_64, vxl_int_64)
104 #endif
105  macro(VIL_PIXEL_FORMAT_UINT_32, vxl_uint_32)
106  macro(VIL_PIXEL_FORMAT_INT_32, vxl_int_32)
107  macro(VIL_PIXEL_FORMAT_UINT_16, vxl_uint_16)
108  macro(VIL_PIXEL_FORMAT_INT_16, vxl_int_16)
111  macro(VIL_PIXEL_FORMAT_COMPLEX_FLOAT , std::complex<float>)
112  macro(VIL_PIXEL_FORMAT_COMPLEX_DOUBLE , std::complex<double>)
113 #undef macro
114  default:
115  return false;
116  }
117 }
An abstract base class of smart pointers to actual image data in memory.
std::complex<float> is a scalar for vil's purposes.
vil_image_resource_sptr src_
Reference to underlying image source.
Definition: vil_transpose.h:34
A generic_image adaptor that behaves like a transposed version of its input.
Definition: vil_transpose.h:31
unsigned ni() const override
Dimensions: Planes x ni x nj.
Definition: vil_transpose.h:41
virtual enum vil_pixel_format pixel_format() const =0
Return a description of the concrete data pixel type.
vil_transpose_image_resource(vil_image_resource_sptr const &)
You can't construct one of these directly, use vil_transpose() instead.
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
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.
unsigned nj() const override
Dimensions: Planes x ni x nj.
Definition: vil_transpose.h:42
#define macro(F, T)
vil_image_view_base_sptr get_view() const
Create a read/write view of all the data.
std::complex<double> is a scalar for vil's purposes.
vil_image_view< T > vil_transpose(const vil_image_view< T > &v)
Create a view which appears as the transpose of this view.
Definition: vil_transpose.h:16