1 /***************************************************************************
2 * This file is part of Tecorrec. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
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. *
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. *
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_
24 * @file tcNegativeProduct.h
25 * @brief Highlights the parts of an image which are dark in all channels.
28 #include "tcChannel.h"
37 /// Highlights the parts of an image which are dark in all channels.
38 class tcNegativeProduct
: public tcChannel
45 * Constructors + destructor
48 /// Primary constructor.
49 tcNegativeProduct(const QList
<tcChannel
*>& inputChannels
);
52 virtual ~tcNegativeProduct();
55 * Main image interface
59 virtual tcChannelConfigWidget
* configWidget();
66 void loadParams(const QString
& filename
);
71 * Interface for derived class to implement
75 virtual void roundPortion(double* x1
, double* y1
, double* x2
, double* y2
);
78 virtual tcAbstractPixelData
* loadPortion(double x1
, double y1
, double x2
, double y2
, bool changed
);
86 /// Emitted when the threshold text changes.
87 void thresholdChanged(const QString
& threshold
);
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.
125 /// Load parameters from a file.
134 /// Calculate an error using some channel as a classifier.
135 float calculateError(tcChannel
* classifier
);
144 QList
<tcChannel
*> m_inputChannels
;
146 /// Whether threshold is enabled.
147 bool m_thresholdEnabled
;
149 /// Threshold to classify shadows.
152 /// Powers to raise the negative channels to.
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
;