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();
63 * Interface for derived class to implement
67 virtual void roundPortion(double* x1
, double* y1
, double* x2
, double* y2
);
70 virtual tcAbstractPixelData
* loadPortion(double x1
, double y1
, double x2
, double y2
);
78 /// Emitted when the threshold text changes.
79 void thresholdChanged(const QString
& threshold
);
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.
114 /// Load parameters from a file.
123 /// Calculate an error using some channel as a classifier.
124 float calculateError(tcChannel
* classifier
);
133 QList
<tcChannel
*> m_inputChannels
;
135 /// Whether threshold is enabled.
136 bool m_thresholdEnabled
;
138 /// Threshold to classify shadows.
141 /// Powers to raise the negative channels to.
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
;