1 // This file is part of OpenCV project. 2 // It is subject to the license terms in the LICENSE file found in the top-level directory 3 // of this distribution and at http://opencv.org/license.html. 4 5 /* 6 * MIT License 7 * 8 * Copyright (c) 2018 Pedro Diamel Marrero Fernández 9 * 10 * Permission is hereby granted, free of charge, to any person obtaining a copy 11 * of this software and associated documentation files (the "Software"), to deal 12 * in the Software without restriction, including without limitation the rights 13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 * copies of the Software, and to permit persons to whom the Software is 15 * furnished to do so, subject to the following conditions: 16 * 17 * The above copyright notice and this permission notice shall be included in all 18 * copies or substantial portions of the Software. 19 * 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 * SOFTWARE. 27 */ 28 29 #ifndef _MCC_GRAPH_CLUSTERS_HPP 30 #define _MCC_GRAPH_CLUSTERS_HPP 31 32 namespace cv 33 { 34 namespace mcc 35 { 36 37 class CB0cluster 38 { 39 public: 40 CB0cluster(); 41 ~CB0cluster(); 42 setVertex(const std::vector<cv::Point> & V)43 inline void setVertex(const std::vector<cv::Point> &V) { X = V; } setB0(const std::vector<double> & b0)44 inline void setB0(const std::vector<double> &b0) { B0 = b0; } setWeight(const std::vector<double> & Weight)45 inline void setWeight(const std::vector<double> &Weight) { W = Weight; } 46 47 void group(); 48 getGroup(std::vector<int> & g)49 void getGroup(std::vector<int> &g) { g = G; } 50 51 private: 52 //entrada 53 std::vector<cv::Point> X; 54 std::vector<double> B0; 55 std::vector<double> W; 56 57 //salida 58 std::vector<int> G; 59 60 private: 61 template <typename T> find(const std::vector<T> & A,std::vector<int> & indx)62 void find(const std::vector<T> &A, std::vector<int> &indx) 63 { 64 indx.clear(); 65 for (int i = 0; i < (int)A.size(); i++) 66 if (A[i]) 67 indx.push_back(i); 68 } 69 }; 70 71 } // namespace mcc 72 } // namespace cv 73 74 #endif //_MCC_GRAPH_CLUSTERS_HPP 75