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_makro_iontracks.h
Go to the documentation of this file.
1 /************************************
2  * added: ??.01.2019 *
3  * author: David Eilenstein *
4  * contact: D.Eilenstein@gsi.de *
5  * project: ImageD *
6  * facility: GSI Darmstadt, Ger *
7  ************************************/
8 
9 #ifndef D_MAKRO_IONTRACKS_H
10 #define D_MAKRO_IONTRACKS_H
11 
12 //own
13 #include <d_enum.h>
14 #include <d_error_handler.h>
15 #include <d_img_proc.h>
16 #include <d_plot.h>
17 #include <d_stat.h>
18 #include <d_viewer.h>
19 #include <d_storage.h>
20 #include <d_component.h>
21 #include <d_component_list.h>
23 #include <d_table.h>
24 
25 //Qt
26 #include <QMainWindow>
27 #include <QFileDialog>
28 #include <QFileInfo>
29 #include <QFileInfoList>
30 #include <QDir>
31 #include <QDateTime>
32 #include <QComboBox>
33 #include <QCloseEvent>
34 #include <QResizeEvent>
35 #include <QInputDialog>
36 
37 //Qt::Charts
38 #include <QChartView>
39 #include <QChart>
40 
41 //general
42 #include <iostream>
43 #include <sstream>
44 #include <fstream>
45 #include <vector>
46 #include <algorithm>
47 
48 //openCV
49 #include <opencv2/core/core.hpp>
50 #include <opencv2/highgui/highgui.hpp>
51 #include <opencv2/imgproc/imgproc.hpp>
52 
53 //namespaces
54 using namespace std;
55 //using namespace cv; (prohibited because of abigous names with qtdatavisualization)
56 #include <d_opencv_typedefs.h>
57 
58 namespace Ui {
59 class D_MAKRO_IonTracks;
60 }
61 
62 class D_MAKRO_IonTracks : public QMainWindow
63 {
64  Q_OBJECT
65 
66 public:
67  explicit D_MAKRO_IonTracks(D_Storage *pStorage, QWidget *parent = 0);
69 
70  void closeEvent(QCloseEvent *event);
71  void resizeEvent(QResizeEvent *event);
72  void set_ClosingPossible(bool closeable) {ClosingPossible = closeable;}
73 
74 private slots:
75 
76  void Update_Views();
77  void Update_View_Proc();
78  void Update_Ui();
79 
80  void Update_ImgProc();
81  void Update_ImgProc_Proc(int start_step);
82  void Update_Step_Proc(int img, int step);
83 
84  void Calc_All();
85  void Calc_ValueDistribution();
86  void Calc_Track_Stats();
87  void Calc_Stack_Stats_All();
88 
89  void Update_Results();
90 
91  void Plot_StatAtRadius_All();
92  void Plot_StatAtRadius_All_Group();
93  void Plot_MeanSD_All();
94  void Plot_MedianADM_All();
95  void Plot_Quantiles_All();
96 
97  void Table_SingleTrack();
98  void Table_TrackStats();
99 
100  void Image_ColorRGB_Info();
101 
102  void Update_Dimensions();
103  void Init_ImageVectors();
104 
105  void Populate_CB_Single(QComboBox *CB, QStringList QSL);
106  void Populate_CB_All();
107  void Populate_CB_Stats();
108  void Populate_CB_AxeTrans();
109  void Populate_CB_PlotTypes();
110  void Populate_CB_TableTypes();
111  void Populate_CB_Dimensions();
112  void Populate_CB_Groups();
113  void Populate_CB_ProcSteps();
114  void Populate_CB_ImageRGB_Info();
115 
116  void Load_DirectoriesList();
117  void Load_Directoty();
118 
119  void Save_Analysis();
120  void Save_Table();
121  void Save_Plot();
122  void Save_Plot(QString path);
123 
124  void on_spinBox_ProcSet_Blur_Size_valueChanged(int arg1);
125  void on_doubleSpinBox_ProcSet_Blur_Sigma_valueChanged(double arg1);
126  void on_doubleSpinBox_ProcSet_Binarization_Thres_valueChanged(double arg1);
127  void on_doubleSpinBox_ProcSet_ExLarge_MaxArea_valueChanged(double arg1);
128  void on_doubleSpinBox_ProcSet_ExAsphere_MinSphere_valueChanged(double arg1);
129  void on_spinBox_ProcSet_SafetyDist_MinRadius_valueChanged(int arg1);
130  void on_doubleSpinBox_ProcSet_ExConn_MinSphere_valueChanged(double arg1);
131  void on_doubleSpinBox_ProcSet_TOI_RelRadius_valueChanged(double arg1);
132 
133  void on_comboBox_ResTab_Group_currentIndexChanged(int index);
134 
135  void on_comboBox_ResPlo_Group_currentIndexChanged(int index);
136 
137 private:
138  //interface
139  Ui::D_MAKRO_IonTracks *ui;
140  bool ClosingPossible = false;
141 
142  //Storage
143  D_Storage *pStore;
144 
145  //Data Base
146  vector<vector<Mat>> vvMA_Proc_ImgStep;
147  vector<D_Value_Distribution_List> vVD_ValDistLists_Img;
148 
149  //Data All
150  vector<vector<vector<double>>> vvvd_All_StaRadTra;
151  vector<vector<vector<double>>> vvvd_All_StaStaRad;
152  //Data Lateral
153  vector<vector<vector<vector<double>>>> vvvvd_Lat_DimStaRadTra;
154  vector<vector<vector<vector<double>>>> vvvvd_Lat_DimStaStaRad;
155  //Data Depth
156  vector<vector<vector<vector<double>>>> vvvvd_Dep_DimStaRadTra;
157  vector<vector<vector<vector<double>>>> vvvvd_Dep_DimStaStaRad;
158 
159  //Calc checks
160  bool calced_ImgProc = false;
161  bool calced_ValDist = false;
162  bool calced_StaTra = false;
163  bool calced_StaSta = false;
164 
165  //Viewer
166  D_Viewer View_Proc;
167  D_Viewer View_Results;
168 
169  //Plot
170  QChartView *pChartView_Plot;
171 
172  //Table
173  D_Table Table_Tracks;
174 
175  //Dimensions
176  int Dim_XLat_Dim = 2;
177  int Dim_YLat_Dim = 2;
178  int Dim_ZDep_Dim = 20;
179  int Dim_Lat_Dim = 4;
180  int Dim_All = 80;
181  double Dim_XLat_Step = 100.0;
182  double Dim_YLat_Step = 100.0;
183  double Dim_ZDep_Step = 5.0;
184  QString Dim_Unit = "µm";
185  QStringList QSL_Dim_Lat;
186  QStringList QSL_Dim_Dep;
187  int Index_CurrentView();
188  void Update_Max_Radius();
189  int max_radius = 8;
190  int tracks_count;
191 
192  //Paths
193  QDir DIR_MasterDirectory;
194  QStringList QSL_ImageDirectories;
195  QStringList QSL_ImageDirectories_Names;
196  QDir DIR_Input;
197  QFileInfoList FIL_InputCurrentSet;
198  QString QS_CurrentSetName;
199  QDir DIR_SaveAnalysis_Master;
200  QDir DIR_SaveAnalysis_Current;
201 
202  //error handling
203  D_Error_Handler ER;
204  void ERR(int err, QString func = "not specified", QString detail = "not specified");
205 
206  //CONSTANTS
207 
208  QStringList QSL_Radius;
209 
210  //Proc Steps
211  enum ProcStepsSingle
212  {
213  c_STEP_LOAD,
214  c_STEP_BLUR,
215  c_STEP_BIN,
216  c_STEP_EX_LARGE,
217  c_STEP_EX_ASPHERES,
218  c_STEP_SAFETY_DIST,
219  c_STEP_EX_CONNECTED,
220  c_STEP_TOI_ORIGINAL,
221  c_STEP_TOI_CENTROID,
222  c_STEP_TOI_AREA,
223  c_STEP_TOI_LABEL,
224  c_STEP_NUMBER_OF
225  };
226  QStringList QSL_ProcStepSingle =
227  {
228  "00 - Load",
229  "01 - Blur",
230  "02 - Binarization",
231  "03 - Exclude Large",
232  "04 - Exclude Aspheres",
233  "05 - Safety Distance",
234  "06 - Exclude Connected",
235  "07 - Tracks of Interest",
236  "08 - Centroids",
237  "09 - Areas",
238  "10 - Labels"
239  };
240 
241  //result types
242  enum ResultTypes
243  {
244  c_RES_IMG,
245  c_RES_TABLE,
246  c_RES_PLOT
247  };
248 
249  //plot types
250  enum PlotTypes
251  {
252  c_PLO_STAT_AT_RADIUS,
253  c_PLO_MEAN_SD,
254  c_PLO_MEDIAN_ADM,
255  c_PLO_QUANTILES,
256  c_PLO_STAT_AT_RADIUS_ALL,
257  c_PLO_NUMBER_OF
258  };
259  QStringList QSL_PlotTypes =
260  {
261  "Stat at radius",
262  "Mean and standard deviation",
263  "Median and average absolute deviation from median",
264  "Quantiles",
265  "Stat at radius (grouped)"
266  };
267 
268  //table types
269  enum TableTypes
270  {
271  c_TAB_RAW,
272  c_TAB_STAT
273  };
274  QStringList QSL_TableTypes =
275  {
276  "Single Tracks",
277  "Statistics for all Tracks"
278  };
279 
280  //groups
281  enum GroupTypes
282  {
283  c_GRP_ALL,
284  c_GRP_LATERAL,
285  c_GRP_DEPTH
286  };
287  QStringList QSL_GroupsResolution =
288  {
289  "All",
290  "Lateral",
291  "Depth"
292  };
293 
294  //image channel infos
295  enum ImageInfoRGB
296  {
297  c_IMG_BINARY,
298  c_IMG_TOI,
299  c_IMG_ROI,
300  c_IMG_EX_LARGE,
301  c_IMG_EX_ASPHERE,
302  c_IMG_SAPHETY_RADIUS,
303  c_IMG_EX_CONNECTED
304  };
305  QStringList QSL_ImageInfoRGB =
306  {
307  "Binary",
308  "Tracks of Interest",
309  "Region of Interes",
310  "Excluded Large",
311  "Excluded Aspheres",
312  "Saphety Radius",
313  "Exclude Connected"
314  };
315 };
316 
317 #endif // D_MAKRO_IONTRACKS_H
c_AXE_POLAR_RADIUS
@ c_AXE_POLAR_RADIUS
Definition: d_enum.h:2144
Mat
cv::Mat Mat
Definition: d_opencv_typedefs.h:28
D_Viewer::Update_View
void Update_View()
D_Viewer::Update_View Starts the workflow to show an image.
Definition: d_viewer.cpp:2096
c_AXE_TRANS_LOG_10
@ c_AXE_TRANS_LOG_10
Definition: d_enum.h:2160
d_component.h
c_STAT_QUANTIL_80
@ c_STAT_QUANTIL_80
Definition: d_enum.h:770
d_viewer.h
d_plot.h
c_STAT_MINIMUM
@ c_STAT_MINIMUM
Definition: d_enum.h:754
D_Img_Proc::Feature_Select
static int Feature_Select(Mat *pMA_Out, Mat *pMA_In, int feature, double f_min, double f_max, int connectivity=4)
Definition: d_img_proc.cpp:15710
QSL_AxeTrans_x
const QStringList QSL_AxeTrans_x
Definition: d_enum.h:2165
d_makro_iontracks.h
D_Img_Proc::Load_From_Path
static int Load_From_Path(Mat *pMA_Out, QFileInfo FI_path)
Definition: d_img_proc.cpp:16
D_Viewer
The D_Viewer class Display images (Mat) in QGraphicsView in the user interface.
Definition: d_viewer.h:58
d_value_distribution_list.h
D_Storage
The D_Storage class Used for storing data. There is only one instance in D_MainWindow .
Definition: d_storage.h:49
ER_size_missmatch
@ ER_size_missmatch
Definition: d_enum.h:141
D_Img_Proc::Normalize
static int Normalize(Mat *pMA_Out, Mat *pMA_In, unsigned int norm, unsigned int type, double min, double max)
Definition: d_img_proc.cpp:3814
D_Viewer::Update_Image
void Update_Image(Mat *MA_new)
D_Viewer::Update_Image Set and show image.
Definition: d_viewer.cpp:2079
c_STAT_ABS_DEV_MED
@ c_STAT_ABS_DEV_MED
Definition: d_enum.h:775
D_MAKRO_IonTracks
Definition: d_makro_iontracks.h:63
c_AXE_TRANS_LIN
@ c_AXE_TRANS_LIN
Definition: d_enum.h:2157
d_table.h
D_Table::Save_Table
QString Save_Table()
Definition: d_table.cpp:186
D_Img_Proc::Labeling
static int Labeling(Mat *pMA_Out, Mat *pMA_In, int connectivity, int out_depth)
Definition: d_img_proc.cpp:12350
D_Table::set_TW
void set_TW(QTableWidget *TW)
Definition: d_table.cpp:16
D_Error_Handler::ERR
void ERR(int err, QString sender, QString func, QString detail)
D_Error_Handler::ERR pops an error message if an error occured and/or streams it to a csv file.
Definition: d_error_handler.cpp:23
c_STAT_MAXIMUM
@ c_STAT_MAXIMUM
Definition: d_enum.h:774
D_Img_Proc::Duplicate
static int Duplicate(Mat *pMA_Out, Mat *pMA_In)
Definition: d_img_proc.cpp:2397
D_MAKRO_IonTracks::set_ClosingPossible
void set_ClosingPossible(bool closeable)
Definition: d_makro_iontracks.h:72
c_STAT_QUANTIL_60
@ c_STAT_QUANTIL_60
Definition: d_enum.h:766
D_MAKRO_IonTracks::closeEvent
void closeEvent(QCloseEvent *event)
Definition: d_makro_iontracks.cpp:111
D_MAKRO_IonTracks::resizeEvent
void resizeEvent(QResizeEvent *event)
Definition: d_makro_iontracks.cpp:127
c_GEO_CENTROID
@ c_GEO_CENTROID
Definition: d_enum.h:2049
D_Img_Proc::Threshold_Relative_1C
static int Threshold_Relative_1C(Mat *pMA_Out, Mat *pMA_In, double max_val, double thres_rel)
Definition: d_img_proc.cpp:6352
c_STAT_STAN_DEV_TOTAL
@ c_STAT_STAN_DEV_TOTAL
Definition: d_enum.h:750
c_STAT_MEDIAN
@ c_STAT_MEDIAN
Definition: d_enum.h:764
d_img_proc.h
D_Table
The D_Table class Display tables in QTableWidget in the user interface.
Definition: d_table.h:42
D_Error_Handler
The D_Error_Handler class takes error codes from D_ERROR_ENUM and shows a popup if an error occures.
Definition: d_error_handler.h:38
D_Plot::Plot_Line_XY_Multi
static int Plot_Line_XY_Multi(QChartView *pChartView, vector< vector< double >> vv_XY_Data, QString name_title, QString name_series, QString name_x, QString name_y, int x_trans=c_AXE_TRANS_LIN, int y_trans=c_AXE_TRANS_LIN, bool dots_visible=false, bool heat_color=false, bool heat_color_AllColors=false, Qt::Alignment legend_pos=Qt::AlignTop)
D_Table::set_data_d_2D_qsl_qsl
void set_data_d_2D_qsl_qsl(vector< vector< double >> vv_data, QStringList qsl_col_names, QStringList qsl_row_names)
Definition: d_table.cpp:74
MORPH_DILATE
const int MORPH_DILATE
Definition: d_opencv_typedefs.h:88
c_STAT_QUANTIL_40
@ c_STAT_QUANTIL_40
Definition: d_enum.h:762
c_STAT_QUANTIL_20
@ c_STAT_QUANTIL_20
Definition: d_enum.h:758
D_Table::clear_data
void clear_data()
Definition: d_table.cpp:148
c_FEAT_SPHERICITY
@ c_FEAT_SPHERICITY
Definition: d_enum.h:1323
d_component_list.h
D_Viewer::set_GV
void set_GV(QGraphicsView *GV_ui)
Definition: d_viewer.cpp:49
QSL_AxeTrans_y
const QStringList QSL_AxeTrans_y
Definition: d_enum.h:2173
D_Plot::Plot_Empty
static int Plot_Empty(QChartView *pChartView, QString QS_Text="No_Additional_Information")
Definition: d_plot.cpp:16
Ui
Definition: d_analysiswindow.h:58
D_Storage::dir_M_IonTracks
QDir * dir_M_IonTracks()
Definition: d_storage.h:79
D_Img_Proc::Morphology_Elemental
static int Morphology_Elemental(Mat *pMA_Out, Mat *pMA_In, int morph_type, int elem_type, unsigned int elem_size_X, unsigned int elem_size_Y, int border_type, unsigned int iterations)
Definition: d_img_proc.cpp:7041
c_AXE_TRANS_1pXX
@ c_AXE_TRANS_1pXX
Definition: d_enum.h:2162
D_Img_Proc::Reduce_Outlines
static int Reduce_Outlines(Mat *pMA_Out, Mat *pMA_In, int neighborhood=8, int thickness=1)
Definition: d_img_proc.cpp:16469
d_storage.h
MORPH_ELLIPSE
const int MORPH_ELLIPSE
Definition: d_opencv_typedefs.h:87
D_Plot::Plot_Line_XY_Single
static int Plot_Line_XY_Single(QChartView *pChartView, vector< double > v_XY_Data, QString name_title, QString name_series, QString name_x, QString name_y, int x_trans=c_AXE_TRANS_LIN, int y_trans=c_AXE_TRANS_LIN, bool dots_visible=false, bool man_axis_style_x=false, bool man_axis_style_y=false, double man_min_x=0, double man_max_x=1, double man_min_y=0, double man_max_y=1, int ticks_x=AXE_TICK_COUNT_MAJOR_DEFAULT, int ticks_y=AXE_TICK_COUNT_MAJOR_DEFAULT)
Definition: d_plot.cpp:3432
d_opencv_typedefs.h
D_Viewer::connect_Zoom
void connect_Zoom(D_Viewer *viewer)
Definition: d_viewer.cpp:128
D_MAKRO_IonTracks::D_MAKRO_IonTracks
D_MAKRO_IonTracks(D_Storage *pStorage, QWidget *parent=0)
Definition: d_makro_iontracks.cpp:12
QSL_StatList
const QStringList QSL_StatList
Definition: d_enum.h:797
d_enum.h
c_STAT_NUMBER_OF_STATS
@ c_STAT_NUMBER_OF_STATS
Definition: d_enum.h:795
D_Img_Proc::Reduce_Geometric
static int Reduce_Geometric(Mat *pMA_Out, Mat *pMA_In, int geometric, int connectivity=8, int thickness=1, uchar value=255)
Definition: d_img_proc.cpp:16215
D_Viewer::Save_Image
QString Save_Image()
D_Viewer::Save_Image Saves the image at FI_LastSaved.
Definition: d_viewer.cpp:2157
D_Img_Proc::Math_ImgImg_BitAnd
static int Math_ImgImg_BitAnd(Mat *pMA_Out, Mat *pMA_In1, Mat *pMA_In2)
Definition: d_img_proc.cpp:13187
d_error_handler.h
D_Img_Proc::Merge
static int Merge(Mat *pMA_Out, Mat *pMA_In0, Mat *pMA_In1, Mat *pMA_In2, Mat *pMA_In3, unsigned int channels, bool channel_use[4])
Definition: d_img_proc.cpp:4060
BORDER_DEFAULT
const int BORDER_DEFAULT
Definition: d_opencv_typedefs.h:78
D_Table::Save_Table_Dialog
QString Save_Table_Dialog()
Definition: d_table.cpp:158
D_Storage::set_dir_M_IonTracks
void set_dir_M_IonTracks(QString path)
Definition: d_storage.h:107
D_Storage::get_Adress
Mat * get_Adress(size_t pos)
Definition: d_storage.h:54
D_Img_Proc::Filter_Gauss
static int Filter_Gauss(Mat *pMA_Out, Mat *pMA_In, int size_x, int size_y, int border, double sigma_x, double sigma_y)
Definition: d_img_proc.cpp:9083
D_Stat::Calc_Stats
static int Calc_Stats(vector< double > *v_stats, vector< double > v_data, bool calc_sorted)
Definition: d_stat.cpp:16
D_MAKRO_IonTracks::~D_MAKRO_IonTracks
~D_MAKRO_IonTracks()
Definition: d_makro_iontracks.cpp:104
c_FEAT_AREA
@ c_FEAT_AREA
Definition: d_enum.h:1347
c_STAT_MEAN_ARITMETIC
@ c_STAT_MEAN_ARITMETIC
Definition: d_enum.h:740
ER_index_out_of_range
@ ER_index_out_of_range
Definition: d_enum.h:146
d_stat.h