31 #include <drain/Log.h>
32 #include <drain/Type.h>
33 #include <drain/TypeUtils.h>
42 #include <drain/Castable.h>
43 #include <drain/CastableIterator.h>
45 #include "drain/util/Point.h"
46 #include "drain/util/VariableMap.h"
49 #include "Intensity.h"
50 #include "ImageFrame.h"
51 #include "ImageChannel.h"
55 #define DRAIN_IMAGE "drain::Image v3.0 2017/10 Markus.Peura@fmi.fi"
82 this->conf.setConf(conf);
95 void setGeometry(
size_t width,
size_t height,
size_t imageChannels=1,
size_t alphaChannels=0){
96 conf.getGeometry().set(width, height, imageChannels, alphaChannels);
103 conf.channels.set(imageChannels, alphaChannels);
110 conf.channels.set(channelGeom);
111 conf.area.set(areaGeom);
131 void setChannelCount(
size_t ni,
size_t na = 0){
132 conf.channels.set(ni, na);
138 void setAlphaChannelCount(
size_t k){
139 conf.channels.setAlphaChannelCount(k);
155 void initialize(
const std::type_info &t,
size_t width,
size_t height,
size_t imageChannels=1,
size_t alphaChannels=0){
157 setGeometry(width, height, imageChannels, alphaChannels);
198 Image(
const std::type_info & t,
size_t width,
size_t height,
size_t channelCount=1,
size_t alphaChannelCount=0){
207 Image(
size_t width,
size_t height,
size_t channelCount=1,
size_t alphaChannelCount=0){
210 initialize(
typeid(
unsigned char), width, height, channelCount, alphaChannelCount);
235 operator const Channel &()
const {
237 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
238 mout.error(
"Image: no channels for cast op");
242 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
243 mout.warn(
"several channels (" , conf.
getChannelCount() ,
"), returning first." );
245 return getChannel(0);
249 operator Channel &(){
251 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
252 mout.error(
"Image: no channels for cast op");
256 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
257 mout.warn(
"several channels (" , conf.
getChannelCount() ,
"), returning first." );
259 return getChannel(0);
269 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
271 if (!conf.isEmpty()){
272 mout.
note(
"STYLE/ changing type of allocated image" );
274 conf.setGeometry(getGeometry());
299 setConf(src.getConf());
321 void dump(std::ostream &ostr = std::cout)
const;
325 void adoptScaling(
const ImageConf & src,
const std::type_info & t =
typeid(
void)){
327 if (t ==
typeid(
void))
333 void swap(
Image & img);
338 std::ostream & operator<<(std::ostream &ostr,
const Image &image){
339 image.toStream(ostr);
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Logger & note(const TT &... args)
For top-level information.
Definition: Log.h:485
tuplebase_t & assignSequence(T &sequence, bool LENIENT=false)
Proposed for tuples only; derived classes should not shadow this.
Definition: TupleBase.h:244
static const std::type_info & getTypeInfo(char t)
Returns the base type associated with a character key.
Definition: Type.h:134
virtual const ValueScaling & getScaling() const
Get linear scaling.
Definition: ValueScaling.h:147
void adoptScaling(const drain::ValueScaling &srcScaling, const std::type_info &srcType, const std::type_info &dstType=typeid(void))
Sets scale and offset according to physical range and current type.
Definition: ValueScaling.cpp:73
Definition: Geometry.h:49
Image with static geometry.
Definition: ImageChannel.h:60
const std::type_info & getType() const
Linear scaling.
Definition: ImageConf.h:110
Definition: Geometry.h:145
size_t getChannelCount() const
Set...
Definition: Geometry.h:257
Struct for image (excluding data)
Definition: ImageConf.h:333
Image with static geometry.
Definition: ImageFrame.h:67
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 copyData(const ImageFrame &src)
Copies data. Does not change encoding, geometry, or coordinate policy.
Definition: ImageFrame.cpp:209
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition: Image.h:184
Image(size_t width, size_t height, size_t channelCount=1, size_t alphaChannelCount=0)
The constructor for unsigned char image of given size.
Definition: Image.h:207
Image(const ImageFrame &image)
Copies the geometry of another image.
Definition: Image.h:222
void setType(const std::type_info &type)
Sets the storage type of the image - typically unsigned char, unsigned int or float.
Definition: Image.h:268
void copyDeep(const ImageFrame &src)
Copies the type, geometry, coordinate policy and data of the given image.
Definition: Image.h:314
void setType(const T &t)
Sets type of the image, applying character mapping of Type::setType(char c) . TODO: drain::Type.
Definition: Image.h:290
void copyShallow(const ImageFrame &src)
Copies type, geometry and coordinate under/overflow policy of the given image. Does not copy the data...
Definition: Image.h:298
Image(const ImageConf &conf)
Copies the geometry of another image.
Definition: Image.h:228
Image(const std::type_info &t=typeid(unsigned char), const Geometry &g=Geometry())
The constructor for an empty image.
Definition: Image.h:190
void dump(std::ostream &ostr=std::cout) const
Prints images geometry, buffer size and type information, and dumps the array contents....
Definition: Image.cpp:43
void setType()
Sets the storage type of the image - typically unsigned char, unsigned int or float.
Definition: Image.h:280
Image(const Image &image)
Copies the geometry of another image.
Definition: Image.h:216
Image(const std::type_info &t, size_t width, size_t height, size_t channelCount=1, size_t alphaChannelCount=0)
The constructor for an image of given type and size.
Definition: Image.h:198
Image with modifiable geometry.
Definition: Image.h:63
void setGeometry(const AreaGeometry &g, size_t imageChannels=1, size_t alphaChannels=0)
Resizes the image, keeps the current type.
Definition: Image.h:102
virtual void setGeometry(size_t width, size_t height, size_t imageChannels=1, size_t alphaChannels=0)
Resizes the image, keeps the current type.
Definition: Image.h:95
virtual void initialize(const std::type_info &t, size_t width, size_t height, size_t imageChannels=1, size_t alphaChannels=0)
Sets the type and allocates a data buffer.
Definition: Image.h:155
void setGeometry(const Geometry &g)
Resizes the image, keeps the current type.
Definition: Image.h:118
virtual void initialize(const std::type_info &t, const Geometry &g)
Sets the type and allocates a data buffer.
Definition: Image.h:147
void resetGeometry()
Collapses the image to undetectValue size, releasing memory.
Definition: Image.h:125
Multi-channel ImageFrame.
Definition: ImageChannel.h:150
Definition: DataSelector.cpp:1277