Commit 57c7b311ca38a1ff7be4fce649fc131517a0a3fb

Authored by Josh Klontz
1 parent 3848bb3c

remove samplefrommask

openbr/plugins/imgproc/samplefrommask.cpp deleted
1   -#include <openbr/plugins/openbr_internal.h>
2   -
3   -using namespace cv;
4   -
5   -namespace br
6   -{
7   -
8   -/*!
9   - * \ingroup transforms
10   - * \brief Samples pixels from a mask.
11   - * \author Scott Klum \cite sklum
12   - */
13   -class SampleFromMaskTransform : public UntrainableTransform
14   -{
15   - Q_OBJECT
16   -
17   - Q_PROPERTY(int minIndices READ get_minIndices WRITE set_minIndices RESET reset_minIndices STORED false)
18   - BR_PROPERTY(int, minIndices, 0)
19   -
20   - void project(const Template &src, Template &dst) const
21   - {
22   - dst = src;
23   -
24   - Mat mask = src.file.get<Mat>("Mask");
25   - Mat indices;
26   - findNonZero(mask,indices);
27   -
28   - if (indices.total() > (size_t)minIndices) {
29   - Mat masked;
30   - src.m().copyTo(masked, mask);
31   - if (src.m().channels() > 1) {
32   - dst.m() = Mat(3,indices.total(),CV_32FC1);
33   - for (size_t j=0; j<indices.total(); j++) {
34   - Vec3b v = masked.at<Vec3b>(indices.at<Point>(j).y,indices.at<Point>(j).x);
35   - dst.m().at<float>(0,j) = v[0];
36   - dst.m().at<float>(1,j) = v[1];
37   - dst.m().at<float>(2,j) = v[2];
38   - }
39   - } else {
40   - dst.m() = Mat(1,indices.total(),src.m().type());
41   -
42   - for (size_t j=0; j<indices.total(); j++)
43   - dst.m().at<uchar>(0,j) = masked.at<uchar>(indices.at<Point>(j).y,indices.at<Point>(j).x);
44   - }
45   - } else {
46   - dst.file.fte = true;
47   - dst.file.remove("Mask");
48   - qWarning("No mask content for %s.",qPrintable(src.file.baseName()));
49   - }
50   - }
51   -};
52   -
53   -BR_REGISTER(Transform, SampleFromMaskTransform)
54   -
55   -} // namespace br
56   -
57   -#include "imgproc/samplefrommask.moc"