Loading...
Searching...
No Matches
ImageChannel.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31#ifndef IMAGE_CHANNEL_H_
32#define IMAGE_CHANNEL_H_ "ImageFrame 0.9, 2011.09.25 Markus.Peura@fmi.fi"
33
34#include <stddef.h> // size_t
35
36
37#include <drain/CastableIterator.h>
38
39#include "ImageFrame.h"
40
41
42namespace drain
43{
44
46namespace image
47{
48
49
51
58class Channel : public ImageFrame {
59
60public:
61
62 inline
63 Channel(){
64 };
65
66 inline
67 Channel(const Channel & channel){
68 //conf.setConf() TOO GENERAL, discards scalingPtr
69 setStorageType(channel.getType());
70 conf.setScaling(channel.getScaling()); // NOTE: pointer-selected
71 conf.setGeometry(channel.getGeometry());
72 setCoordinatePolicy(channel.getCoordinatePolicy());
73 //conf.setConf(channel.getConf());
74
75 // conf.setEncoding(channel.getEncoding());
76 };
77
78 virtual inline
79 Channel & getChannel(size_t i){
80 if (i != 0)
81 throw std::runtime_error("Channel: getChannel(i) with i>0");
82 return *this;
83 };
84
85
86 virtual inline
87 const Channel & getChannel(size_t i) const {
88 if (i != 0)
89 throw std::runtime_error("Channel: getChannel(i) with i>0");
90 return *this;
91 }
92
93 virtual inline
94 Channel & getAlphaChannel(size_t i=0){
95 throw std::runtime_error("Channel: getAlphaChannel() impossible");
96 return *this;
97 };
98
99 virtual inline
100 const Channel & getAlphaChannel(size_t i=0) const {
101 throw std::runtime_error("Channel: getAlphaChannel() impossible");
102 return *this;
103 };
104
105
106};
107
109
112class ChannelView : public Channel {
113
114public:
115
116 inline
117 ChannelView(){
118 };
119
120 inline
121 ChannelView(const ChannelView & channel) : Channel(channel) {
122 //std::cerr << "ChannelView copy constr\n";
123 };
124
125 inline
126 ChannelView(const ImageFrame & src, size_t channel = 0) {
127 setView(src, channel);
128 };
129
130 inline
131 void setView(const ImageFrame & src, size_t channel){
132 ImageFrame::setView(src, channel, 1);
133 conf.channels.set(1,0);
134 }
135
136 inline
137 void setView(const Channel & src){
138 ImageFrame::setView(src, 0, 1);
139 conf.channels.set(1,0);
140 }
141
142
143
144};
145
146
148class MultiChannel : public ImageFrame {
149
150public:
151
152 inline
153 MultiChannel(){};
154
155 inline
156 MultiChannel(const MultiChannel & img){
157 this->conf.setScaling(img.getScaling());
158 };
159
160
161 Channel & getChannel(size_t i);
162
163 const Channel & getChannel(size_t i) const;
164
165 Channel & getAlphaChannel(size_t i=0);
166
167 const Channel & getAlphaChannel(size_t i=0) const;
168
169
170 // hide?
171 inline
172 const std::vector<ChannelView> & getChannelVector() const {
174 return channelVector;
175 };
176
177protected:
178
179 void updateChannelVector() const;
180
181 mutable std::vector<ChannelView> channelVector;
182
183
184};
185
186
187
188} // image::
189} // drain::
190
191#endif /* IMAGE_FRAME_H_*/
192
193// Drain
virtual void setScaling(double scale, double offset)
Set linear scaling.
Definition ValueScaling.h:135
View to a single channel.
Definition ImageChannel.h:112
Image with static geometry.
Definition ImageChannel.h:58
Image with static geometry.
Definition ImageFrame.h:62
void setStorageType(const std::type_info &type)
Sets the storage type of the image - typically unsigned char, unsigned int or float....
Definition ImageFrame.cpp:62
void setView(const ImageFrame &src, size_t channelStart, size_t channelCount, bool catenate=false)
Sets the image to view the data and scaling of another image.
Definition ImageFrame.cpp:142
const CoordinatePolicy & getCoordinatePolicy() const
Coord policy.
Definition ImageLike.h:174
const std::type_info & getType() const
Get the storage type.
Definition ImageLike.h:100
Multi-channel ImageFrame.
Definition ImageChannel.h:148
void updateChannelVector() const
Updates channel vector. Copies scaling of the host image.
Definition ImageChannel.cpp:94
Definition DataSelector.cpp:1277