MMDevice
Loading...
Searching...
No Matches
Debayer.h
Go to the documentation of this file.
1
2// MODULE: Debayer.h
3// SYSTEM: ImageBase subsystem
4// AUTHOR: Jennifer West, jennifer_west@umanitoba.ca,
5// Nenad Amodaj, nenad@amodaj.com
6//
7// DESCRIPTION: Debayer algorithms, adapted from:
8// http://www.umanitoba.ca/faculties/science/astronomy/jwest/plugins.html
9//
10//
11// COPYRIGHT: Jennifer West (University of Manitoba),
12// Exploratorium http://www.exploratorium.edu
13//
14// LICENSE: This file is free for use, modification and distribution and
15// is distributed under terms specified in the BSD license
16// This file is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty
18// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19//
20// IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.
23//
24
25#pragma once
26
27#include "ImgBuffer.h"
28
29#include <string>
30#include <vector>
31
39{
40public:
41 Debayer();
42 ~Debayer();
43
44 int Process(ImgBuffer& out, const ImgBuffer& in, int bitDepth);
45 int Process(ImgBuffer& out, const unsigned char* in, int width, int height, int bitDepth);
46 int Process(ImgBuffer& out, const unsigned short* in, int width, int height, int bitDepth);
47
48 const std::vector<std::string> GetOrders() const {return orders;}
49 const std::vector<std::string> GetAlgorithms() const {return algorithms;}
50
51 void SetOrderIndex(int idx) {orderIndex = idx;}
52 void SetAlgorithmIndex(int idx) {algoIndex = idx;}
53
54private:
55 template <typename T>
56 int ProcessT(ImgBuffer& out, const T* in, int width, int height, int bitDepth);
57 template<typename T>
58 void ReplicateDecode(const T* input, int* out, int width, int height, int bitDepth, int rowOrder);
59 template <typename T>
60 void SmoothDecode(const T* input, int* output, int width, int height, int bitDepth, int rowOrder);
61 template<typename T>
62 int Convert(const T* input, int* output, int width, int height, int bitDepth, int rowOrder, int algorithm);
63 unsigned short GetPixel(const unsigned short* v, int x, int y, int width, int height);
64 void SetPixel(std::vector<unsigned short>& v, unsigned short val, int x, int y, int width, int height);
65 unsigned short GetPixel(const unsigned char* v, int x, int y, int width, int height);
66
67 std::vector<unsigned short> r; // red scratch buffer
68 std::vector<unsigned short> g; // green scratch buffer
69 std::vector<unsigned short> b; // blue scratch buffer
70
71 std::vector<std::string> orders;
72 std::vector<std::string> algorithms;
73
74 int orderIndex;
75 int algoIndex;
76};
Utility class to build a color image from a Bayer grayscale image.
Definition Debayer.h:39
const std::vector< std::string > GetOrders() const
Definition Debayer.h:48
const std::vector< std::string > GetAlgorithms() const
Definition Debayer.h:49
~Debayer()
Definition Debayer.cpp:54
void SetOrderIndex(int idx)
Definition Debayer.h:51
void SetAlgorithmIndex(int idx)
Definition Debayer.h:52
int Process(ImgBuffer &out, const ImgBuffer &in, int bitDepth)
Definition Debayer.cpp:58
Debayer()
Definition Debayer.cpp:37
Definition ImgBuffer.h:28