ImageD  v2_7_5 (24.06.22)
ImageD is an image processing software designed for rapid prototyping and implementing algorithms and solutions for science, research and teaching.
d_component_list.h
Go to the documentation of this file.
1 /************************************
2  * added: 30.11.2018 *
3  * author: David Eilenstein *
4  * contact: D.Eilenstein@gsi.de *
5  * project: ImageD *
6  * facility: GSI Darmstadt, Ger *
7  ************************************/
8 
9 #ifndef D_COMPONENT_LIST_H
10 #define D_COMPONENT_LIST_H
11 
12 //own
13 #include <d_enum.h>
14 #include <d_component.h>
15 
16 //general
17 #include <iostream>
18 #include <vector>
19 #include <algorithm>
20 #include <cmath>
21 #include <fstream>
22 #include <thread>
23 
24 //Qt
25 #include <QString>
26 #include <QDebug>
27 #include <QStringList>
28 #include <QDir>
29 #include <QFileInfo>
30 
31 //openCV
32 #include <opencv2/core/core.hpp>
33 #include <opencv2/highgui/highgui.hpp>
34 #include <opencv2/imgproc/imgproc.hpp>
35 
36 //namespaces
37 using namespace std;
38 //using namespace cv; (prohibited because of abigous names with qtdatavisualization)
39 #include <d_opencv_typedefs.h>
40 
46 {
47 public:
48  //contructor
50  D_Component_List(Mat *pMA_BinaryOrLabel, int connectivity = 8);
51 
52  //init
53  int set_Mat(Mat *pMA_BinaryOrLabel, int connectivity = 8);
54 
55  //get
56  D_Component get_Component(size_t index) {return (index < m_Components.size()) ? m_Components[index] : m_Components[0];}
57  size_t get_size() {return m_Components.size();}
58  vector<D_Component> get_ComponentVector() {return m_Components;}
59 
60  double get_Feature(int comp, int feat) {return m_Components[comp].get_Feature(feat);}
61  vector<double> get_FeatureVector(int feature);
62  vector<double> get_FeatureVector_BG(int feature);
63 
64  Mat get_MatBinary() {return MA_Binary;}
65  Mat *get_pMatBinary() {return &MA_Binary;}
66  Mat get_MatLabels() {return MA_Labels;}
67  Mat *get_pMatLabels() {return &MA_Labels;}
68 
69  Point2f get_Centroid(int comp) {return m_Components[comp].get_Centroid();}
70  vector<Point2f> get_CentroidVector();
71  vector<Point2f> get_CentroidVector_BG();
72 
73  Point get_Offset(int comp) {return m_Components[comp].get_Offset();}
74  vector<Point> get_OffsetVector();
75  vector<Point2f> get_OffsetVector_2f();
76  vector<Point> get_OffsetVector_BG();
77 
78  vector<vector<Point>> get_ContourVector();
79  vector<vector<Point>> get_ContourVector_BG();
80  vector<vector<Point>> get_ContourVector_ConvexHull();
81 
82  vector<Rect> get_BndBox_Rect_Vector();
83  Rect get_BndBox_Rect(int comp) {return m_Components[comp].get_BndBox_Rect();}
84  vector<RotatedRect> get_BndBox_Rotate_Vector();
85  RotatedRect get_BndBox_Rotate(int comp) {return m_Components[comp].get_BndBox_Rotate();}
86  vector<RotatedRect> get_Ellipse_Fitted_Vector();
87  RotatedRect get_Ellipse_Fitted(int comp) {return m_Components[comp].get_Ellipse_Fitted();}
88 
89  vector<Point> get_Coordinates(int comp) {return m_Components[comp].get_Coordinates();}
90 
91 
92  //basics
93  void Components_Updated();
94  size_t size() {return m_Components.size();}
95  void clear() {m_Components.clear();}
96 
97  //save
98  void save_all(QString path_dir);
99 
100 private:
101 
102  Mat MA_Binary;
103  Mat MA_Labels;
104 
105  bool initialized = false;
106  int Split_Labels_2_Components();
107 
108 
109  vector<D_Component> m_Components;
110  bool b_Components() {return static_cast<bool>(m_Components.size());}
111 
112  //stream and save
113  ofstream OS_Save;
114  QDir DIR_Save;
115 
116 };
117 
118 #endif // D_COMPONENT_LIST_H
Mat
cv::Mat Mat
Definition: d_opencv_typedefs.h:28
ER_okay
@ ER_okay
Definition: d_enum.h:133
D_Component_List::clear
void clear()
Definition: d_component_list.h:95
D_Component_List::Components_Updated
void Components_Updated()
Definition: d_component_list.cpp:304
d_component.h
D_Component_List::get_pMatBinary
Mat * get_pMatBinary()
Definition: d_component_list.h:65
Point2f
cv::Point2f Point2f
Definition: d_opencv_typedefs.h:37
D_Component_List::size
size_t size()
Definition: d_component_list.h:94
D_Component_List::get_Offset
Point get_Offset(int comp)
Definition: d_component_list.h:73
Rect
cv::Rect Rect
Definition: d_opencv_typedefs.h:65
D_Component_List::get_CentroidVector
vector< Point2f > get_CentroidVector()
Definition: d_component_list.cpp:148
D_Component_List::get_BndBox_Rotate
RotatedRect get_BndBox_Rotate(int comp)
Definition: d_component_list.h:85
D_Component_List::get_OffsetVector
vector< Point > get_OffsetVector()
Definition: d_component_list.cpp:177
D_Component_List::get_pMatLabels
Mat * get_pMatLabels()
Definition: d_component_list.h:67
D_Component_List::get_size
size_t get_size()
Definition: d_component_list.h:57
QSL_FeatureList
const QStringList QSL_FeatureList
Definition: d_enum.h:1457
D_Component_List::get_Ellipse_Fitted_Vector
vector< RotatedRect > get_Ellipse_Fitted_Vector()
Definition: d_component_list.cpp:291
D_Component
The D_Component class A blob and its features in a 2D binary/label image.
Definition: d_component.h:41
D_Component_List::get_BndBox_Rotate_Vector
vector< RotatedRect > get_BndBox_Rotate_Vector()
Definition: d_component_list.cpp:278
Point
cv::Point Point
Definition: d_opencv_typedefs.h:35
ER_bitdepth_bad
@ ER_bitdepth_bad
Definition: d_enum.h:138
D_Component_List::get_MatLabels
Mat get_MatLabels()
Definition: d_component_list.h:66
D_Component_List::save_all
void save_all(QString path_dir)
Definition: d_component_list.cpp:309
D_Component_List::get_ContourVector_ConvexHull
vector< vector< Point > > get_ContourVector_ConvexHull()
Definition: d_component_list.cpp:252
D_Component_List::get_FeatureVector
vector< double > get_FeatureVector(int feature)
Definition: d_component_list.cpp:119
ER_channel_bad
@ ER_channel_bad
Definition: d_enum.h:144
D_Component_List::get_Component
D_Component get_Component(size_t index)
Definition: d_component_list.h:56
D_Component_List::get_OffsetVector_BG
vector< Point > get_OffsetVector_BG()
Definition: d_component_list.cpp:203
D_Component_List::get_Ellipse_Fitted
RotatedRect get_Ellipse_Fitted(int comp)
Definition: d_component_list.h:87
D_Component_List::get_FeatureVector_BG
vector< double > get_FeatureVector_BG(int feature)
Definition: d_component_list.cpp:132
D_Component_List::get_ComponentVector
vector< D_Component > get_ComponentVector()
Definition: d_component_list.h:58
D_Component_List::get_BndBox_Rect
Rect get_BndBox_Rect(int comp)
Definition: d_component_list.h:83
d_component_list.h
D_Component_List::get_Centroid
Point2f get_Centroid(int comp)
Definition: d_component_list.h:69
D_Component_List::set_Mat
int set_Mat(Mat *pMA_BinaryOrLabel, int connectivity=8)
Definition: d_component_list.cpp:22
D_Component_List::D_Component_List
D_Component_List()
Definition: d_component_list.cpp:11
D_Component_List
The D_Component_List class is a list of D_Component representing the blobs in a binary image.
Definition: d_component_list.h:46
D_Component_List::get_CentroidVector_BG
vector< Point2f > get_CentroidVector_BG()
Definition: d_component_list.cpp:161
D_Component_List::get_OffsetVector_2f
vector< Point2f > get_OffsetVector_2f()
Definition: d_component_list.cpp:190
D_Component_List::get_MatBinary
Mat get_MatBinary()
Definition: d_component_list.h:64
d_opencv_typedefs.h
D_Component_List::get_ContourVector
vector< vector< Point > > get_ContourVector()
Definition: d_component_list.cpp:221
d_enum.h
D_Component_List::get_Feature
double get_Feature(int comp, int feat)
Definition: d_component_list.h:60
RotatedRect
cv::RotatedRect RotatedRect
Definition: d_opencv_typedefs.h:66
ER_parameter_bad
@ ER_parameter_bad
Definition: d_enum.h:142
D_Component_List::get_ContourVector_BG
vector< vector< Point > > get_ContourVector_BG()
Definition: d_component_list.cpp:234
c_FEAT_NUMBER_OF_FEATS
@ c_FEAT_NUMBER_OF_FEATS
Definition: d_enum.h:1455
D_Component_List::get_BndBox_Rect_Vector
vector< Rect > get_BndBox_Rect_Vector()
Definition: d_component_list.cpp:265
D_Component_List::get_Coordinates
vector< Point > get_Coordinates(int comp)
Definition: d_component_list.h:89
ER_empty
@ ER_empty
Definition: d_enum.h:135