Commit 3d39fe7bf07f103138c54489e43ea8f2112617ac

Authored by Josh Klontz
1 parent 2eaf99ee

remove gradient

openbr/plugins/imgproc/gradient.cpp deleted
1   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2   - * Copyright 2012 The MITRE Corporation *
3   - * *
4   - * Licensed under the Apache License, Version 2.0 (the "License"); *
5   - * you may not use this file except in compliance with the License. *
6   - * You may obtain a copy of the License at *
7   - * *
8   - * http://www.apache.org/licenses/LICENSE-2.0 *
9   - * *
10   - * Unless required by applicable law or agreed to in writing, software *
11   - * distributed under the License is distributed on an "AS IS" BASIS, *
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13   - * See the License for the specific language governing permissions and *
14   - * limitations under the License. *
15   - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16   -
17   -#include <opencv2/imgproc/imgproc.hpp>
18   -
19   -#include <openbr/plugins/openbr_internal.h>
20   -
21   -using namespace cv;
22   -
23   -namespace br
24   -{
25   -
26   -/*!
27   - * \ingroup transforms
28   - * \brief Computes magnitude and/or angle of image.
29   - * \author Josh Klontz \cite jklontz
30   - */
31   -class GradientTransform : public UntrainableTransform
32   -{
33   - Q_OBJECT
34   - Q_ENUMS(Channel)
35   - Q_PROPERTY(Channel channel READ get_channel WRITE set_channel RESET reset_channel STORED false)
36   -
37   -public:
38   - enum Channel { Magnitude, Angle, MagnitudeAndAngle };
39   -
40   -private:
41   - BR_PROPERTY(Channel, channel, Angle)
42   -
43   - void project(const Template &src, Template &dst) const
44   - {
45   - Mat dx, dy, magnitude, angle;
46   - Sobel(src, dx, CV_32F, 1, 0, FILTER_SCHARR);
47   - Sobel(src, dy, CV_32F, 0, 1, FILTER_SCHARR);
48   - cartToPolar(dx, dy, magnitude, angle, true);
49   - std::vector<Mat> mv;
50   - if ((channel == Magnitude) || (channel == MagnitudeAndAngle)) {
51   - const float theoreticalMaxMagnitude = sqrt(2*pow(float(2*(3+10+3)*255), 2.f));
52   - mv.push_back(magnitude / theoreticalMaxMagnitude);
53   - }
54   - if ((channel == Angle) || (channel == MagnitudeAndAngle))
55   - mv.push_back(angle);
56   - Mat result;
57   - merge(mv, result);
58   - dst.append(result);
59   - }
60   -};
61   -
62   -BR_REGISTER(Transform, GradientTransform)
63   -
64   -} // namespace br
65   -
66   -#include "imgproc/gradient.moc"
openbr/plugins/imgproc/gradientmask.cpp deleted
1   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2   - * Copyright 2012 The MITRE Corporation *
3   - * *
4   - * Licensed under the Apache License, Version 2.0 (the "License"); *
5   - * you may not use this file except in compliance with the License. *
6   - * You may obtain a copy of the License at *
7   - * *
8   - * http://www.apache.org/licenses/LICENSE-2.0 *
9   - * *
10   - * Unless required by applicable law or agreed to in writing, software *
11   - * distributed under the License is distributed on an "AS IS" BASIS, *
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13   - * See the License for the specific language governing permissions and *
14   - * limitations under the License. *
15   - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16   -
17   -#include <openbr/plugins/openbr_internal.h>
18   -
19   -using namespace cv;
20   -
21   -namespace br
22   -{
23   -
24   -/*!
25   - * \ingroup transforms
26   - * \brief Masks image according to pixel change.
27   - * \author Josh Klontz \cite jklontz
28   - */
29   -class GradientMaskTransform : public UntrainableTransform
30   -{
31   - Q_OBJECT
32   - Q_PROPERTY(int delta READ get_delta WRITE set_delta RESET reset_delta STORED false)
33   - BR_PROPERTY(int, delta, 1)
34   -
35   - void project(const Template &src, Template &dst) const
36   - {
37   - const Mat &m = src.m();
38   - if (m.type() != CV_8UC1) qFatal("Requires 8UC1 matrices.");
39   - Mat n = Mat(m.rows, m.cols, CV_8UC1);
40   - n.setTo(255);
41   - for (int i=0; i<m.rows; i++) {
42   - for (int j=0; j<m.cols; j++) {
43   - if ((i>0) && (abs(m.at<quint8>(i-1,j)-m.at<quint8>(i,j)) > delta)) { n.at<quint8>(i,j) = 0; continue; }
44   - if ((j+1<m.cols) && (abs(m.at<quint8>(i,j+1)-m.at<quint8>(i,j)) > delta)) { n.at<quint8>(i,j) = 0; continue; }
45   - if ((i+1<m.rows) && (abs(m.at<quint8>(i+1,j)-m.at<quint8>(i,j)) > delta)) { n.at<quint8>(i,j) = 0; continue; }
46   - if ((j>0) && (abs(m.at<quint8>(i,j-1)-m.at<quint8>(i,j)) > delta)) { n.at<quint8>(i,j) = 0; continue; }
47   - }
48   - }
49   - dst = n;
50   - }
51   -};
52   -
53   -BR_REGISTER(Transform, GradientMaskTransform)
54   -
55   -} // namespace br
56   -
57   -#include "imgproc/gradientmask.moc"