31 #ifndef DRAIN_IMAGE_OP_H_
32 #define DRAIN_IMAGE_OP_H_
34 #include "drain/util/BeanLike.h"
35 #include "drain/image/CoordinateHandler.h"
91 mout.
error() <<
"not implemented; consider processChannels[Equally|Repeated|Separately]" << mout.endl;
102 throw std::runtime_error(name+
"(ImageOp)::"+__FUNCTION__+
"(src,dst) unimplemented.");
109 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
110 mout.
note(
"using image channels only (discarding alpha channels)" );
145 void help(std::ostream & ostr = std::cout)
const {
156 ImageOp(
const std::string &name = __FUNCTION__,
const std::string &description=
"") :
ImageMod(name, description){
167 bool processOverlappingWithTemp(
const ImageFrame & src,
Image & dst)
const;
174 bool traverseOverlappingWithTemp(
const Channel & src,
Channel & dst)
const;
211 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
212 mout.
debug(
"restoring to trays" );
220 traverseChannels(s, d);
227 Logger mout(getImgLog(), __FILE__, __FUNCTION__);
228 mout.
debug(
"restoring to trays" );
236 traverseChannels(s, d);
258 mout.
debug(
"nothing defined (ok)" );
266 mout.
debug(
"nothing defined (ok)" );
275 std::ostream & operator<<(std::ostream & ostr,
const ImageOp &op){
277 ostr << op.
getName() <<
'(' << op.getParameters() <<
')';
virtual const std::string & getName() const
Return the name of an instance.
Definition: BeanLike.h:69
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Logger & error(const TT &... args)
Echoes.
Definition: Log.h:412
Logger & note(const TT &... args)
For top-level information.
Definition: Log.h:485
Logger & debug(const TT &... args)
Public, yet typically used "internally", when TIMING=true.
Definition: Log.h:676
Image with static geometry.
Definition: ImageChannel.h:60
Definition: CoordinateHandler.h:62
Struct for image (excluding data)
Definition: ImageConf.h:333
Image with static geometry.
Definition: ImageFrame.h:67
const CoordinatePolicy & getCoordinatePolicy() const
Coord policy.
Definition: ImageLike.h:167
Class for operations that modify an existing image instead of producing a new image.
Definition: ImageMod.h:52
virtual int srcAlpha() const
Tell if alpha channel(s) is required in input.
Definition: ImageMod.h:66
Base class for image processing functions.
Definition: ImageOp.h:49
virtual void traverseChannel(const Channel &src, Channel &dst) const
Apply to single channel.
Definition: ImageOp.h:101
virtual void makeCompatible(const ImageConf &src, Image &dst) const
Depending on the operator, modifies the geometry and type of dst.
Definition: ImageOp.cpp:54
void traverseChannelsEqually(const ImageTray< const Channel > &src, ImageTray< Channel > &dst) const
Calls processWithTemp() if the frames overlap.
Definition: ImageOp.cpp:414
virtual void process(const ImageFrame &src, Image &dst) const
Main interface. Typically splits processing to each channel.
Definition: ImageOp.cpp:126
ImageOp(const ImageOp &op)
Definition: ImageOp.h:163
virtual void initializeParameters(const ImageFrame &src, const ImageFrame &dst) const
Set applicable internal parameters before calling traverse().
Definition: ImageOp.h:256
void traverseChannelsRepeated(const ImageTray< const Channel > &src, ImageTray< Channel > &dst) const
Recycle channels until all dst channels completed.
Definition: ImageOp.cpp:454
ImageOp(const std::string &name=__FUNCTION__, const std::string &description="")
Definition: ImageOp.h:156
void traverseAsChannelTrays(const ImageFrame &src, const ImageFrame &srcWeight, ImageFrame &dst, ImageFrame &dstWeight) const
Redirect to processing as trays. This is the opposite of processChannels...() functions.
Definition: ImageOp.h:225
void traverseAsChannelTrays(const ImageFrame &src, ImageFrame &dst) const
Redirect to processing as trays. This is the opposite of processChannels...() functions.
Definition: ImageOp.h:210
void traverseChannelsSeparately(const ImageTray< const Channel > &src, ImageTray< Channel > &dst) const
Process each (src,dst) channel pair independently. Raise error if their counts differ.
Definition: ImageOp.cpp:340
virtual void makeCompatible2(const ImageFrame &src1, const ImageFrame &src2, Image &dst) const
Modifies the geometry and type of dst to fit the computation result.
Definition: ImageOp.cpp:104
virtual void initializeParameters(const ImageFrame &src, const ImageFrame &src2, const ImageFrame &dst) const
Set applicable internal parameters before calling traverse().
Definition: ImageOp.h:263
virtual void traverseChannel(const Channel &src, const Channel &srcAlpha, Channel &dst, Channel &dstAlpha) const
Apply to single channel with alpha.
Definition: ImageOp.h:107
virtual void getDstConf(const ImageConf &src, ImageConf &dst) const
Given source image, determine respective dest image configuration.
Definition: ImageOp.cpp:42
virtual void help(std::ostream &ostr=std::cout) const
Prints name, description and parameters using BeanLike::toOStr(). Virtual, so derived classes may ext...
Definition: ImageOp.h:145
Container applicable for Channels and Images, with alpha support.
Definition: ImageTray.h:267
void setChannels(T2 &img)
Splits.
Definition: ImageTray.h:402
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition: Image.h:184
Definition: DataSelector.cpp:1277