Point Cloud Library (PCL)  1.8.1
openni_image_bayer_grbg.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2011, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  */
38 #include <pcl/pcl_config.h>
39 #ifdef HAVE_OPENNI
40 
41 #ifndef __OPENNI_IMAGE_BAYER_GRBG__
42 #define __OPENNI_IMAGE_BAYER_GRBG__
43 #include <pcl/pcl_macros.h>
44 #include "openni_image.h"
45 
46 namespace openni_wrapper
47 {
48  /** \brief This class provides methods to fill a RGB or Grayscale image buffer from underlying Bayer pattern image.
49  * \author Suat Gedikli <gedikli@willowgarage.com>
50  * \ingroup io
51  */
52  class PCL_EXPORTS ImageBayerGRBG : public Image
53  {
54  public:
55  typedef enum
56  {
57  Bilinear = 0,
59  EdgeAwareWeighted
60  } DebayeringMethod;
61 
62  ImageBayerGRBG (boost::shared_ptr<xn::ImageMetaData> image_meta_data, DebayeringMethod method) throw ();
63  virtual ~ImageBayerGRBG () throw ();
64 
65  inline virtual Encoding
66  getEncoding () const
67  {
68  return (BAYER_GRBG);
69  }
70 
71  virtual void fillRGB (unsigned width, unsigned height, unsigned char* rgb_buffer, unsigned rgb_line_step = 0) const;
72  virtual void fillGrayscale (unsigned width, unsigned height, unsigned char* gray_buffer, unsigned gray_line_step = 0) const;
73  virtual bool isResizingSupported (unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height) const;
74  inline void setDebayeringMethod (const DebayeringMethod& method) throw ();
75  inline DebayeringMethod getDebayeringMethod () const throw ();
76  inline static bool resizingSupported (unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height);
77 
78 
79  protected:
80  DebayeringMethod debayering_method_;
81  };
82 
83  void
84  ImageBayerGRBG::setDebayeringMethod (const ImageBayerGRBG::DebayeringMethod& method) throw ()
85  {
86  debayering_method_ = method;
87  }
88 
91  {
92  return debayering_method_;
93  }
94 
95  bool
96  ImageBayerGRBG::resizingSupported (unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height)
97  {
98  return (output_width <= input_width && output_height <= input_height && input_width % output_width == 0 && input_height % output_height == 0 );
99  }
100 } // namespace
101 
102 #endif
103 #endif // __OPENNI_IMAGE__
static bool resizingSupported(unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height)
Image class containing just a reference to image meta data.
Definition: openni_image.h:58
This class provides methods to fill a RGB or Grayscale image buffer from underlying Bayer pattern ima...
DebayeringMethod getDebayeringMethod() const