Basic elevation optimisation channel
[tecorrec.git] / geo / tcNegativeProduct.h
blob17668ab1268fd834c39d3c56f301d3b3797ba1ae
1 /***************************************************************************
2 * This file is part of Tecorrec. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * Tecorrec is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * Tecorrec is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with Tecorrec. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef _tcNegativeProduct_h_
21 #define _tcNegativeProduct_h_
23 /**
24 * @file tcNegativeProduct.h
25 * @brief Highlights the parts of an image which are dark in all channels.
28 #include "tcChannel.h"
30 #include <QList>
32 class QSlider;
33 class QLabel;
34 class QComboBox;
36 /// Highlights the parts of an image which are dark in all channels.
37 class tcNegativeProduct : public tcChannel
39 Q_OBJECT
41 public:
44 * Constructors + destructor
47 /// Primary constructor.
48 tcNegativeProduct(const QList<tcChannel*>& inputChannels);
50 /// Destructor.
51 virtual ~tcNegativeProduct();
54 * Main image interface
57 // Reimplemented
58 virtual tcChannelConfigWidget* configWidget();
60 protected:
63 * Interface for derived class to implement
66 // Reimplemented
67 virtual void roundPortion(double* x1, double* y1, double* x2, double* y2);
69 // Reimplemented
70 virtual tcAbstractPixelData* loadPortion(double x1, double y1, double x2, double y2);
72 signals:
75 * Signals
78 /// Emitted when the threshold text changes.
79 void thresholdChanged(const QString& threshold);
81 private slots:
84 * Private slots
87 /// Set whether the theshold is enabled.
88 void setThresholdEnabled(bool thresholdEnabled);
90 /// Move the theshold value slider.
91 void moveThreshold(int threshold);
93 /// Set the theshold value.
94 void setThreshold(int threshold);
96 /// Indicates that the power slider of a channel has moved.
97 void movePower(int channel);
99 /// Indicates that the power of a channel has changed.
100 void changePower(int channel);
102 /// Optimise the threshold for the parameters using a classification channel.
103 void optimiseThreshold();
105 /// Save threshold errors.
106 void saveThresholdErrors();
108 /// Optimise the parameters using a classification channel.
109 void optimiseParameters();
111 /// Save parameters to a file.
112 void saveParams();
114 /// Load parameters from a file.
115 void loadParams();
117 private:
120 * Private functions
123 /// Calculate an error using some channel as a classifier.
124 float calculateError(tcChannel* classifier);
126 private:
129 * Variables
132 /// Input channels.
133 QList<tcChannel*> m_inputChannels;
135 /// Whether threshold is enabled.
136 bool m_thresholdEnabled;
138 /// Threshold to classify shadows.
139 float m_threshold;
141 /// Powers to raise the negative channels to.
142 float* m_powers;
144 /// Filename in which to save threshold-error values.
145 QString m_saveThresholdError;
147 /// Filename in which to save parameter-error values.
148 QString m_saveParametersError;
150 /// Filename in which to save parameters.
151 QString m_saveParameters;
153 /// Configuration widget.
154 tcChannelConfigWidget* m_configWidget;
156 /// Threshold slider.
157 QSlider* m_sliderThreshold;
159 /// Power sliders in config widget.
160 QList<QSlider*> m_powerSliders;
162 /// Power sliders labelsin config widget.
163 QList<QLabel*> m_powerLabels;
165 /// Classifier channel.
166 QComboBox* m_comboClassifier;
168 /// Slider for log learning rate.
169 QSlider* m_sliderLearningRate;
171 /// Label to show error.
172 QLabel* m_labelError;
174 /// Last calculated optimal threshold error.
175 int m_optimalThresholdError;
178 #endif