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"
36 /// Highlights the parts of an image which are dark in all channels.
37 class tcNegativeProduct
: public tcChannel
44 * Constructors + destructor
47 /// Primary constructor.
48 tcNegativeProduct(const QList
<tcChannel
*>& inputChannels
);
51 virtual ~tcNegativeProduct();
54 * Main image interface
58 virtual tcChannelConfigWidget
* configWidget();
65 void loadParams(const QString
& filename
);
70 * Interface for derived class to implement
74 virtual void roundPortion(double* x1
, double* y1
, double* x2
, double* y2
);
77 virtual tcAbstractPixelData
* loadPortion(double x1
, double y1
, double x2
, double y2
, bool changed
);
85 /// Emitted when the threshold text changes.
86 void thresholdChanged(const QString
& threshold
);
94 /// Set whether the theshold is enabled.
95 void setThresholdEnabled(bool thresholdEnabled
);
97 /// Move the theshold value slider.
98 void moveThreshold(int threshold
);
100 /// Set the theshold value.
101 void setThreshold(int threshold
);
103 /// Indicates that the power slider of a channel has moved.
104 void movePower(int channel
);
106 /// Indicates that the power of a channel has changed.
107 void changePower(int channel
);
109 /// Optimise the threshold for the parameters using a classification channel.
110 void optimiseThreshold();
112 /// Save threshold errors.
113 void saveThresholdErrors();
115 /// Optimise the parameters using a classification channel.
116 void optimiseParameters();
118 /// Save parameters to a file.
121 /// Load parameters from a file.
130 /// Calculate an error using some channel as a classifier.
131 float calculateError(tcChannel
* classifier
);
140 QList
<tcChannel
*> m_inputChannels
;
142 /// Whether threshold is enabled.
143 bool m_thresholdEnabled
;
145 /// Threshold to classify shadows.
148 /// Powers to raise the negative channels to.
151 /// Filename in which to save threshold-error values.
152 QString m_saveThresholdError
;
154 /// Filename in which to save parameter-error values.
155 QString m_saveParametersError
;
157 /// Filename in which to save parameters.
158 QString m_saveParameters
;
160 /// Configuration widget.
161 tcChannelConfigWidget
* m_configWidget
;
163 /// Threshold slider.
164 QSlider
* m_sliderThreshold
;
166 /// Power sliders in config widget.
167 QList
<QSlider
*> m_powerSliders
;
169 /// Power sliders labelsin config widget.
170 QList
<QLabel
*> m_powerLabels
;
172 /// Classifier channel.
173 QComboBox
* m_comboClassifier
;
175 /// Slider for log learning rate.
176 QSlider
* m_sliderLearningRate
;
178 /// Label to show error.
179 QLabel
* m_labelError
;
181 /// Last calculated optimal threshold error.
182 int m_optimalThresholdError
;