Commit e9ff5ce4bcc284c66dbf6a91a2b085cc18f77d25

Authored by Josh Klontz
1 parent d94307b9

remove watershedsegmentation

openbr/plugins/imgproc/watershedsegmentation.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   -#include <openbr/core/opencvutils.h>
21   -
22   -using namespace cv;
23   -
24   -namespace br
25   -{
26   -
27   -/*!
28   - * \ingroup transforms
29   - * \brief Applies watershed segmentation.
30   - * \author Austin Blanton \cite imaus10
31   - */
32   -class WatershedSegmentationTransform : public UntrainableTransform
33   -{
34   - Q_OBJECT
35   - void project(const Template &src, Template &dst) const
36   - {
37   - dst = src;
38   -
39   - Mat mod;
40   -// adaptiveThreshold(src.m(), src.m(), 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 33, 5);
41   - threshold(src.m(), mod, 0, 255, THRESH_BINARY+THRESH_OTSU);
42   -
43   - // findContours requires an 8-bit 1-channel image
44   - // and modifies its source image
45   - if (mod.depth() != CV_8U) OpenCVUtils::cvtUChar(mod, mod);
46   - if (mod.channels() != 1) OpenCVUtils::cvtGray(mod, mod);
47   - std::vector<std::vector<Point> > contours;
48   - std::vector<Vec4i> hierarchy;
49   - findContours(mod, contours, hierarchy, RETR_CCOMP, CHAIN_APPROX_SIMPLE);
50   -
51   - // draw the contour delineations as 1,2,3... for input to watershed
52   - Mat markers = Mat::zeros(mod.size(), CV_32S);
53   - int compCount=0;
54   - for (int idx=0; idx>=0; idx=hierarchy[idx][0], compCount++) {
55   - drawContours(markers, contours, idx, Scalar::all(compCount+1), -1, 8, hierarchy, INT_MAX);
56   - }
57   -
58   - Mat orig = src.m();
59   - // watershed requires a 3-channel 8-bit image
60   - if (orig.channels() == 1) cvtColor(orig, orig, COLOR_GRAY2BGR);
61   - watershed(orig, markers);
62   - dst.file.set("SegmentsMask", QVariant::fromValue(markers));
63   - dst.file.set("NumSegments", compCount);
64   - }
65   -};
66   -
67   -BR_REGISTER(Transform, WatershedSegmentationTransform)
68   -
69   -} // namespace br
70   -
71   -#include "imgproc/watershedsegmentation.moc"