Boost GIL


Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
image_view< Loc > Class Template Reference

A lightweight object that interprets memory as a 2D array of pixels. Models ImageViewConcept,PixelBasedConcept,HasDynamicXStepTypeConcept,HasDynamicYStepTypeConcept,HasTransposedTypeConcept. More...

#include <image_view.hpp>

Public Types

using value_type = typename Loc::value_type
 
using reference = typename Loc::reference
 
using coord_t = typename Loc::coord_t
 
using difference_type = coord_t
 
using point_t = typename Loc::point_t
 
using locator = Loc
 
using const_t = image_view< typename Loc::const_t >
 
using iterator = iterator_from_2d< Loc >
 
using const_iterator = typename const_t::iterator
 
using const_reference = typename const_t::reference
 
using pointer = typename std::iterator_traits< iterator >::pointer
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using size_type = std::size_t
 
using xy_locator = locator
 
using x_iterator = typename xy_locator::x_iterator
 
using y_iterator = typename xy_locator::y_iterator
 
using x_coord_t = typename xy_locator::x_coord_t
 
using y_coord_t = typename xy_locator::y_coord_t
 

Public Member Functions

 image_view (image_view const &img_view)
 
template<typename View >
 image_view (View const &view)
 
template<typename L2 >
 image_view (point_t const &dims, L2 const &loc)
 
template<typename L2 >
 image_view (coord_t width, coord_t height, L2 const &loc)
 
template<typename View >
image_viewoperator= (View const &view)
 
image_viewoperator= (image_view const &view)
 
template<typename View >
bool operator== (View const &view) const
 
template<typename View >
bool operator!= (View const &view) const
 
void swap (image_view< Loc > &other)
 Exchanges the elements of the current view with those of other in constant time. More...
 
auto dimensions () const -> point_t const &
 
auto pixels () const -> locator const &
 
auto width () const -> x_coord_t
 
auto height () const -> y_coord_t
 
auto num_channels () const -> std::size_t
 
bool is_1d_traversable () const
 
bool empty () const
 Returns true if the view has no elements, false otherwise. More...
 
auto front () const -> reference
 Returns a reference to the first element in raster order. More...
 
auto back () const -> reference
 Returns a reference to the last element in raster order. More...
 

Static Public Attributes

static const std::size_t num_dimensions =2
 

Friends

template<typename L2 >
class image_view
 
template<typename L2 >
void swap (image_view< L2 > &lhs, image_view< L2 > &rhs)
 

1D navigation

auto size () const -> size_type
 
auto begin () const -> iterator
 
auto end () const -> iterator
 
auto rbegin () const -> reverse_iterator
 
auto rend () const -> reverse_iterator
 
auto operator[] (difference_type i) const -> reference
 
auto at (difference_type i) const -> iterator
 
auto at (point_t const &p) const -> iterator
 
auto at (x_coord_t x, y_coord_t y) const -> iterator
 

2-D navigation

auto operator() (point_t const &p) const -> reference
 
auto operator() (x_coord_t x, y_coord_t y) const -> reference
 
template<std::size_t D>
auto axis_iterator (point_t const &p) const -> typename axis< D >::iterator
 
auto xy_at (x_coord_t x, y_coord_t y) const -> xy_locator
 
auto xy_at (point_t const &p) const -> xy_locator
 

X navigation

auto x_at (x_coord_t x, y_coord_t y) const -> x_iterator
 
auto x_at (point_t const &p) const -> x_iterator
 
auto row_begin (y_coord_t y) const -> x_iterator
 
auto row_end (y_coord_t y) const -> x_iterator
 

Y navigation

auto y_at (x_coord_t x, y_coord_t y) const -> y_iterator
 
auto y_at (point_t const &p) const -> y_iterator
 
auto col_begin (x_coord_t x) const -> y_iterator
 
auto col_end (x_coord_t x) const -> y_iterator
 

Detailed Description

template<typename Loc>
class boost::gil::image_view< Loc >

A lightweight object that interprets memory as a 2D array of pixels. Models ImageViewConcept,PixelBasedConcept,HasDynamicXStepTypeConcept,HasDynamicYStepTypeConcept,HasTransposedTypeConcept.

Image view consists of a pixel 2D locator (defining the mechanism for navigating in 2D) and the image dimensions.

Image views to images are what ranges are to STL containers. They are lightweight objects, that don't own the pixels. It is the user's responsibility that the underlying data remains valid for the lifetime of the image view.

Similar to iterators and ranges, constness of views does not extend to constness of pixels. A const image_view does not allow changing its location in memory (resizing, moving) but does not prevent one from changing the pixels. The latter requires an image view whose value_type is const.

Images have interfaces consistent with STL 1D random access containers, so they can be used directly in STL algorithms like:

std::fill(img.begin(), img.end(), red_pixel);

In addition, horizontal, vertical and 2D random access iterators are provided.

Note also that image_view does not require that its element type be a pixel. It could be instantiated with a locator whose value_type models only Regular. In this case the image view models the weaker RandomAccess2DImageViewConcept, and does not model PixelBasedConcept. Many generic algorithms don't require the elements to be pixels.

Member Function Documentation

◆ back()

auto back ( ) const -> reference
inline

Returns a reference to the last element in raster order.

Note
Required by the ForwardCollection, since view model the concept.
See also
https://www.boost.org/libs/utility/Collection.html

◆ empty()

bool empty ( ) const
inline

Returns true if the view has no elements, false otherwise.

Note
Required by the Collection concept
See also
https://www.boost.org/libs/utility/Collection.html

◆ front()

auto front ( ) const -> reference
inline

Returns a reference to the first element in raster order.

Note
Required by the ForwardCollection, since view model the concept.
See also
https://www.boost.org/libs/utility/Collection.html

◆ swap()

void swap ( image_view< Loc > &  other)
inline

Exchanges the elements of the current view with those of other in constant time.

Note
Required by the Collection concept
See also
https://www.boost.org/libs/utility/Collection.html

The documentation for this class was generated from the following file: