32#ifndef DRAIN_IMAGE_TRAY 
   33#define DRAIN_IMAGE_TRAY 
   52class 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;
 
 
  254std::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) {
 
 
  512std::ostream & operator<<(std::ostream &ostr, 
const ImageTray<T> & tray){
 
  513    ostr << 
"ChannelTray " << tray.getGeometry() << 
":\n";
 
  545     *  \param image - image object to be referenced
 
  546     *  Notice: if image contains alpha channels, they will \e not be separated.
 
  548    Clip(image_t & image){
 
  554       \param image - image object, the image channels of which will referenced.
 
  555       \param alpha - image object, the image channels of which will referenced as alpha channels.
 
  556       Notice: if first argument contains alpha channels, they will \e not be separated.
 
  558     TODO: consider if empty alpha?
 
  560    Clip(image_t & image, image_t & alpha){
 
  569    const Geometry & getGeometry() const {
 
  570        geometry.setGeometry(this->get().getGeometry());
 
  571        geometry.setChannelCount(this->size(), this->alpha.size());
 
  574    // TODO consider setGeometry
 
  580    void appendAlpha(image_t & image){
 
  581        alpha.insert(typename map_t::value_type(alpha.size(), image));
 
  586    bool hasAlpha() const {
 
  587        return !alpha.empty();
 
  592    // TODO: if no explicit alpha, return images alpha?
 
  595    const image_t & getAlpha(size_t i = 0) const {
 
  596        typename map_t::const_iterator it = alpha.find(i);
 
  597        if (it == alpha.end()){
 
  598            std::runtime_error("ImageTray::getAlpha(i): find failed");
 
  606    image_t & getAlpha(size_t i = 0){
 
  607        typename map_t::iterator it = alpha.find(i);
 
  608        if (it == alpha.end()){
 
  609            std::runtime_error("ImageTray::getAlpha(i): find failed");
 
  616    void toOStr(std::ostream & ostr) const {
 
  617        Tray<T>::toOStr(ostr);
 
  619        for (typename Tray<T>::map_t::const_iterator it=alpha.begin(); it!=alpha.end(); ++it){
 
  620            ostr << '\t' << it->first << ':' << it->second << '\n';
 
  628    void setAlpha(size_t i, image_t & image){
 
  629        alpha.insert(typename map_t::value_type(i, image));
 
  635    void append(image_t & image){
 
  636        throw std::runtime_error("Clip::append defunct");
 
  637        //this->insert(typename map_t::value_type(this->size(), image));
 
  640    mutable Geometry geometry;
 
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
const Geometry & getGeometry() const
Appends the whole single image.
Definition ImageTray.h:315
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
image_t & getAlpha(size_t i=0)
Returns the i'th alpha image.
Definition ImageTray.h:380
void copy(const Tray< T2 > &t)
Add image sequence.
Definition ImageTray.h:346
const image_t & getAlpha(size_t i=0) const
Returns the i'th alpha image.
Definition ImageTray.h:329
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
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
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
image_t & get(size_t i=0)
Returns the i'th image.
Definition ImageTray.h:91
virtual const Geometry & getGeometry() const
Returns the geometry of the first frame.
Definition ImageTray.h:135
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
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