tcElevationOptimization: fix typo s/write/read/
[tecorrec.git] / geo / tcNegativeProduct.h
blob345e3a56e1839fbe4c84aacd4e122345100002da
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 QSpinBox;
34 class QLabel;
35 class QComboBox;
37 /// Highlights the parts of an image which are dark in all channels.
38 class tcNegativeProduct : public tcChannel
40 Q_OBJECT
42 public:
45 * Constructors + destructor
48 /// Primary constructor.
49 tcNegativeProduct(const QList<tcChannel*>& inputChannels);
51 /// Destructor.
52 virtual ~tcNegativeProduct();
55 * Main image interface
58 // Reimplemented
59 virtual tcChannelConfigWidget* configWidget();
62 * Parameters
65 /// Load parameters.
66 void loadParams(const QString& filename);
68 protected:
71 * Interface for derived class to implement
74 // Reimplemented
75 virtual void roundPortion(double* x1, double* y1, double* x2, double* y2);
77 // Reimplemented
78 virtual tcAbstractPixelData* loadPortion(double x1, double y1, double x2, double y2, bool changed);
80 signals:
83 * Signals
86 /// Emitted when the threshold text changes.
87 void thresholdChanged(const QString& threshold);
89 private slots:
92 * Private slots
95 /// Set whether the theshold is enabled.
96 void setThresholdEnabled(bool thresholdEnabled);
98 /// Move the theshold value slider.
99 void moveThreshold(int threshold);
101 /// Set the theshold value.
102 void setThreshold(int threshold);
104 /// Indicates that the power slider of a channel has moved.
105 void movePower(int channel);
107 /// Indicates that the power of a channel has changed.
108 void changePower(int channel);
110 /// Optimize the threshold for the parameters using a classification channel.
111 void optimizeThreshold();
113 /// Save threshold errors.
114 void saveThresholdErrors();
116 /// Optimize the parameters using a classification channel.
117 void optimizeParameters();
119 /// Calculate errors.
120 void calculateError();
122 /// Save parameters to a file.
123 void saveParams();
125 /// Load parameters from a file.
126 void loadParams();
128 private:
131 * Private functions
134 /// Calculate an error using some channel as a classifier.
135 float calculateError(tcChannel* classifier);
137 private:
140 * Variables
143 /// Input channels.
144 QList<tcChannel*> m_inputChannels;
146 /// Whether threshold is enabled.
147 bool m_thresholdEnabled;
149 /// Threshold to classify shadows.
150 float m_threshold;
152 /// Powers to raise the negative channels to.
153 float* m_powers;
155 /// Filename in which to save threshold-error values.
156 QString m_saveThresholdError;
158 /// Filename in which to save parameter-error values.
159 QString m_saveParametersError;
161 /// Filename in which to save parameters.
162 QString m_saveParameters;
164 /// Configuration widget.
165 tcChannelConfigWidget* m_configWidget;
167 /// Threshold slider.
168 QSlider* m_sliderThreshold;
170 /// Power sliders in config widget.
171 QList<QSlider*> m_powerSliders;
173 /// Power sliders labelsin config widget.
174 QList<QLabel*> m_powerLabels;
176 /// Classifier channel.
177 QComboBox* m_comboClassifier;
179 /// Slider for log learning rate.
180 QSlider* m_sliderLearningRate;
182 /// Spinbox for subsampling.
183 QSpinBox* m_subsample;
185 /// Label to show error.
186 QLabel* m_labelError;
188 /// Last calculated optimal threshold error.
189 int m_optimalThresholdError;
192 #endif