Loading...
Searching...
No Matches
TransposeOp.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31#ifndef TRANSPOSEOP2_H_
32#define TRANSPOSEOP2_H_
33
34#include <cstdarg>
35
36#include "ImageOp.h"
37
38
39namespace drain
40{
41namespace image
42{
43
45
53class TransposeOp: public ImageOp
54{
55public:
56
58
62 TransposeOp(): ImageOp(__FUNCTION__,"Flips image matrix around its corner."){
63 // link("threshold", this->threshold = threshold);
64 };
65
66 virtual inline
67 void getDstConf(const ImageConf & src, ImageConf & dst) const {
68 //virtual void make Compatible(const ImageFrame &src,Image &dst) const {
69
70 drain::Logger mout(getImgLog(), __FILE__, __FUNCTION__);
71
72 // unneeded if (!dst.typeIsSet()) dst.setType(src.getType());
73
74 const size_t & width = src.getWidth();
75 const size_t & height = src.getHeight();
76 const size_t & iChannels = src.getImageChannelCount();
77 const size_t & aChannels = src.getAlphaChannelCount();
78
79 /*
80 if ((dst.getHeight()==width) && (dst.getWidth()==height) &&
81 (dst.getImageChannelCount()==iChannels) && (dst.getAlphaChannelCount()==aChannels) ){
82 mout.debug("dst with ok geometry" );
83 return;
84 }
85 */
86
88 dst.setGeometry(height, width, iChannels, aChannels);
89
90 const CoordinatePolicy & pol = src.getCoordinatePolicy();
92 pol.yUnderFlowPolicy,
93 pol.xUnderFlowPolicy,
94 pol.yOverFlowPolicy,
95 pol.xUnderFlowPolicy
96 );
97
98 mout.debug("dst:" , dst );
99
100 };
101
102 inline
103 void traverseChannels(const ImageTray<const Channel> & src, ImageTray<Channel> & dst) const {
104 drain::Logger mout(getImgLog(), __FILE__, __FUNCTION__); //REP (this->name+"[const ChannelTray &, ChannelTray &]", __FUNCTION__);
106 }
107
108
109 inline
110 void traverseChannel(const Channel & src, Channel & dst) const {
111
112 for (size_t j = 0; j < src.getHeight(); ++j) {
113 for (size_t i = 0; i < src.getWidth(); ++i) {
114 dst.put(j, i, src.get<double>(i,j));
115 }
116 }
117
118 }
119
120 //double threshold;
121
122
123protected:
124
125};
126
127
128
129
130
131}
132}
133
134#endif /*THRESHOLD_H_*/
135
136// Drain
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & debug(const TT &... args)
Debug information.
Definition Log.h:666
Image with static geometry.
Definition ImageChannel.h:60
Policies for coordinate underflows and overflows.
Definition CoordinatePolicy.h:106
Struct for image (excluding data)
Definition ImageConf.h:333
void setCoordinatePolicy(const T &policy)
Does not set any CoordinateHandler object.
Definition ImageConf.h:368
void put(size_t i, T x)
Sets the intensity in location i to x. See \address.
Definition ImageFrame.h:192
T get(size_t i) const
Gets the intensity at location i. See address().
Definition ImageFrame.h:254
Base class for image processing functions.
Definition ImageOp.h:49
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
Container applicable for Channels and Images, with alpha support.
Definition ImageTray.h:267
Transpose operator. Swaps the intensities over the diagonal exis.
Definition TransposeOp.h:54
virtual void getDstConf(const ImageConf &src, ImageConf &dst) const
Given source image, determine respective dest image configuration.
Definition TransposeOp.h:67
void traverseChannel(const Channel &src, Channel &dst) const
Apply to single channel.
Definition TransposeOp.h:110
TransposeOp()
Default constructor.
Definition TransposeOp.h:62
Definition DataSelector.cpp:1277