32 #ifndef DRAIN_IMAGE_TRAY
33 #define DRAIN_IMAGE_TRAY
39 #include "ImageView.h"
52 class Tray :
public std::map<size_t, T &> {
57 typedef std::map<size_t, image_t &> map_t;
81 const image_t &
get(
size_t i = 0)
const {
82 typename map_t::const_iterator it = this->find(i);
83 if (it == this->end()){
84 throw std::runtime_error(
"Tray::get(i): find failed");
91 image_t &
get(
size_t i = 0){
92 typename map_t::iterator it = this->find(i);
93 if (it == this->end()){
94 throw std::runtime_error(
"Tray::get(i): find failed");
103 void set(image_t & img,
size_t i=0){
104 this->insert(
typename map_t::value_type(i, img));
110 this->insert(
typename map_t::value_type(this->size(), img));
128 for (
typename std::vector<T2>::iterator it = v.begin(); it != v.end(); ++it) {
138 geometry.channels.set(this->size());
149 if (g != it->second.getGeometry())
171 typename map_t::iterator it=this->begin();
172 typename std::vector<T2>::const_iterator vit = v.begin();
173 while (it!=this->end()){
174 it->second.put(p, *vit);
185 typename std::vector<T2>::iterator vit = v.begin();
186 typename map_t::const_iterator it=this->begin();
187 while (it!=this->end()){
188 *vit = it->second.template get<T2>(p);
218 bool hasOverlap(
const Tray<T2> & tray)
const {
219 for (
typename map_t::const_iterator it=this->begin(); it!=this->end(); ++it){
221 if (it->second.hasOverlap(it2->second)){
231 void toOStr(std::ostream & ostr)
const {
232 for (
typename map_t::const_iterator it=this->begin(); it!=this->end(); ++it){
233 ostr << it->first <<
':' << it->second <<
'\n';
237 void createVector(std::vector<Image> & v)
const {
238 for (
typename map_t::const_iterator it=this->begin(); it!=this->end(); ++it){
240 v.insert(v.end(), Image(it->second.getType()));
246 mutable Geometry geometry;
254 std::ostream & operator<<(std::ostream &ostr,
const Tray<T> & tray){
255 ostr <<
"Tray " << tray.getGeometry() <<
":\n";
272 typedef typename Tray<T>::image_t image_t;
273 typedef typename Tray<T>::map_t map_t;
317 this->geometry.channels.set(this->size(), this->alpha.size());
318 return this->geometry;
322 bool hasAlpha()
const {
323 return !alpha.empty();
330 typename map_t::const_iterator it = alpha.find(i);
331 if (it == alpha.end()){
332 throw std::runtime_error(
"ChannelTray::getAlpha(i): find failed");
340 this->alpha.Tray<T>::clear();
361 this->alpha.Tray<T>::copy(t.alpha);
368 alpha.Tray<T>::copy(t.alpha);
375 this->alpha.insert(
typename map_t::value_type(i, img));
381 typename map_t::iterator it = alpha.find(i);
382 if (it == alpha.end()){
383 throw std::runtime_error(
"ChannelTray::getAlpha(i): find failed");
404 takeAlphaChannels(alpha, img);
411 takeAlphaChannels(alpha, img);
423 void setChannels(
const T2 & img,
const T2 & alphaImg){
451 void toOStr(std::ostream & ostr = std::cout)
const {
454 if (this->hasAlpha()){
455 ostr <<
"alphas: " << std::endl;
456 alpha.Tray<T>::toOStr(ostr);
470 for (
size_t i = 0; i < img.getImageChannelCount(); ++i) {
477 void takeAlphaChannels(
Tray<T> & tray, T2 & img){
479 for (
size_t i = 0; i < img.getAlphaChannelCount(); ++i) {
492 for (
size_t i = 0; i < img.getImageChannelCount(); ++i) {
499 void takeAlphaChannels(
Tray<const T> & tray,
const T2 & img){
501 for (
size_t i = 0; i < img.getAlphaChannelCount(); ++i) {
512 std::ostream & operator<<(std::ostream &ostr,
const ImageTray<T> & tray){
513 ostr <<
"ChannelTray " << tray.getGeometry() <<
":\n";
Definition: Geometry.h:145
Container applicable for Channels and Images, with alpha support.
Definition: ImageTray.h:267
void setAlphaChannels(const T2 &img)
Splits.
Definition: ImageTray.h:444
void setChannels(T2 &img)
Splits.
Definition: ImageTray.h:402
void setAlphaChannels(T2 &img)
Splits.
Definition: ImageTray.h:434
void setAlpha(image_t &img, size_t i=0)
Replace image in position i.
Definition: ImageTray.h:374
static void takeImageChannels(Tray< T > &tray, T2 &img)
Splits.
Definition: ImageTray.h:468
void copy(const Tray< T2 > &t)
Add image sequence.
Definition: ImageTray.h:346
void copy(Tray< T2 > &t)
Add image sequence.
Definition: ImageTray.h:353
void appendAlpha(image_t &img)
Add image to the end of the container.
Definition: ImageTray.h:391
image_t & getAlpha(size_t i=0)
Returns the i'th alpha image.
Definition: ImageTray.h:380
const image_t & getAlpha(size_t i=0) const
Returns the i'th alpha image.
Definition: ImageTray.h:329
const Geometry & getGeometry() const
Appends the whole single image.
Definition: ImageTray.h:315
static void takeImageChannels(Tray< const T > &tray, const T2 &img)
Splits.
Definition: ImageTray.h:490
Set of images, usable for general calls of type traverseFrame(src, dst) .
Definition: ImageTray.h:52
image_t & get(size_t i=0)
Returns the i'th image.
Definition: ImageTray.h:91
virtual void appendImage(image_t &img)
Add image to the end.
Definition: ImageTray.h:109
void putPixel(const Point2D< int > &p, const std::vector< T2 > &v)
Put intensity vector.
Definition: ImageTray.h:170
virtual bool checkGeometry(const Geometry &g) const
Returns true, if all the frames have the same width and height.
Definition: ImageTray.h:144
void copy(const Tray< T2 > &t)
Add image sequence. Replaces old values.
Definition: ImageTray.h:116
const image_t & get(size_t i=0) const
Returns the i'th image.
Definition: ImageTray.h:81
virtual const Geometry & getGeometry() const
Returns the geometry of the first frame.
Definition: ImageTray.h:135
void copyVector(std::vector< T2 > &v)
Add image sequence.
Definition: ImageTray.h:126
void set(image_t &img, size_t i=0)
Replace image in position i.
Definition: ImageTray.h:103
void getPixel(const Point2D< int > &p, std::vector< T2 > &v) const
Get intensity vector.
Definition: ImageTray.h:184
bool checkGeometry() const
Returns true, if all the frames have the same width and height.
Definition: ImageTray.h:156
Definition: DataSelector.cpp:1277