36#include <drain/CastableIterator.h>
40#include "ImageFrame.h"
41#include "ImageChannel.h"
45#define DRAIN_IMAGE "drain::Image v3.0 2017/10 Markus.Peura@fmi.fi"
74 this->conf.setConf(conf);
87 void setGeometry(
size_t width,
size_t height,
size_t imageChannels=1,
size_t alphaChannels=0){
88 conf.getGeometry().set(width, height, imageChannels, alphaChannels);
95 conf.channels.set(imageChannels, alphaChannels);
102 conf.channels.set(channelGeom);
103 conf.area.set(areaGeom);
123 void setChannelCount(
size_t ni,
size_t na = 0){
124 conf.channels.set(ni, na);
130 void setAlphaChannelCount(
size_t k){
131 conf.channels.setAlphaChannelCount(k);
147 void initialize(
const std::type_info &t,
size_t width,
size_t height,
size_t imageChannels=1,
size_t alphaChannels=0){
149 setGeometry(width, height, imageChannels, alphaChannels);
158 bool suggestType(
const std::type_info &t)
override;
197 Image(
const std::type_info & t,
size_t width,
size_t height,
size_t channelCount=1,
size_t alphaChannelCount=0){
206 Image(
size_t width,
size_t height,
size_t channelCount=1,
size_t alphaChannelCount=0){
209 initialize(
typeid(
unsigned char), width, height, channelCount, alphaChannelCount);
234 operator const Channel &()
const {
236 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
237 mout.error(
"Image: no channels for cast op");
241 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
242 mout.warn(
"several channels (" , conf.
getChannelCount() ,
"), returning first." );
244 return getChannel(0);
248 operator Channel &(){
250 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
251 mout.error(
"Image: no channels for cast op");
255 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
256 mout.warn(
"several channels (" , conf.
getChannelCount() ,
"), returning first." );
258 return getChannel(0);
268 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
270 if (!conf.isEmpty()){
271 mout.
note(
"STYLE/ changing type of allocated image" );
273 conf.setGeometry(getGeometry());
298 setConf(src.getConf());
320 void dump(std::ostream &ostr = std::cout)
const;
324 void adoptScaling(
const ImageConf & src,
const std::type_info & t =
typeid(
void)){
326 if (t ==
typeid(
void))
332 void swap(
Image & img);
337std::ostream & operator<<(std::ostream &ostr,
const Image &image){
338 image.toStream(ostr);
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:313
Logger & note(const TT &... args)
For top-level information.
Definition Log.h:490
tuplebase_t & assignSequence(T &sequence, bool LENIENT=false)
Proposed for tuples only; derived classes should not shadow this.
Definition TupleBase.h:287
static const std::type_info & getTypeInfo(char t)
Returns the base type associated with a character key.
Definition Type.h:131
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
virtual const ValueScaling & getScaling() const
Get linear scaling.
Definition ValueScaling.h:146
Image with static geometry.
Definition ImageChannel.h:58
const std::type_info & getType() const
Linear scaling.
Definition ImageConf.h:110
Definition Geometry.h:143
size_t getChannelCount() const
Set...
Definition Geometry.h:255
Struct for image (excluding data)
Definition ImageConf.h:333
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 copyData(const ImageFrame &src)
Copies data. Does not change encoding, geometry, or coordinate policy.
Definition ImageFrame.cpp:236
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:183
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:206
Image(const ImageFrame &image)
Copies the geometry of another image.
Definition Image.h:221
void setType(const std::type_info &type)
Sets the storage type of the image - typically unsigned char, unsigned int or float.
Definition Image.h:267
void copyDeep(const ImageFrame &src)
Copies the type, geometry, coordinate policy and data of the given image.
Definition Image.h:313
void setType(const T &t)
Sets type of the image, applying character mapping of Type::setType(char c) . TODO: drain::Type.
Definition Image.h:289
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:297
Image(const ImageConf &conf)
Copies the geometry of another image.
Definition Image.h:227
Image(const std::type_info &t=typeid(unsigned char), const Geometry &g=Geometry())
The constructor for an empty image.
Definition Image.h:189
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:279
Image(const Image &image)
Copies the geometry of another image.
Definition Image.h:215
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:197
Image with modifiable geometry.
Definition Image.h:53
void setGeometry(const AreaGeometry &g, size_t imageChannels=1, size_t alphaChannels=0)
Resizes the image, keeps the current type.
Definition Image.h:94
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:87
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:147
void setGeometry(const Geometry &g)
Resizes the image, keeps the current type.
Definition Image.h:110
virtual bool requireGeometry(const Geometry &geometry) override
Change geometry. This overrides the behavior of ImageFrame::requireGeometry().
Definition Image.cpp:103
virtual bool suggestType(const std::type_info &t) override
Change type. This overrides the behavior of ImageFrame::suggestType().
Definition Image.cpp:93
virtual void initialize(const std::type_info &t, const Geometry &g)
Sets the type and allocates a data buffer.
Definition Image.h:139
void resetGeometry()
Collapses the image to undetectValue size, releasing memory.
Definition Image.h:117
Multi-channel ImageFrame.
Definition ImageChannel.h:148
Definition DataSelector.cpp:1277