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_analysiswindow.h
Go to the documentation of this file.
1 /************************************
2  * added: 17.12.2018 *
3  * author: David Eilenstein *
4  * contact: D.Eilenstein@gsi.de *
5  * project: ImageD *
6  * facility: GSI Darmstadt, Ger *
7  ************************************/
8 
9 #ifndef D_ANALYSISWINDOW_H
10 #define D_ANALYSISWINDOW_H
11 
12 //own
13 #include <d_enum.h>
14 #include <d_stat.h>
15 #include <d_component.h>
16 #include <d_component_list.h>
18 #include <d_plot.h>
19 #include <d_img_proc.h>
20 #include <d_storage.h>
21 #include <d_viewer.h>
22 #include <d_table.h>
23 
24 //general
25 #include <iostream>
26 #include <vector>
27 #include <fstream>
28 #include <sstream>
29 
30 //Qt
31 #include <QMainWindow>
32 #include <QImage>
33 #include <QPainter>
34 #include <QPen>
35 #include <QColor>
36 #include <QFileInfo>
37 #include <QDir>
38 #include <QString>
39 #include <QDebug>
40 #include <QInputDialog>
41 #include <QComboBox>
42 #include <QElapsedTimer>
43 
44 //Qt::Charts
45 #include <QChartView>
46 #include <QChart>
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_AnalysisWindow;
60 }
61 
67 class D_AnalysisWindow : public QMainWindow
68 {
69  Q_OBJECT
70 
71 public:
72  explicit D_AnalysisWindow(D_Storage *pStorage, QWidget *parent = 0);
74 
75  void resizeEvent(QResizeEvent* event);
76 
77 private slots:
78 
79  void Image_Label_Get();
80  void Image_Binary_Add();
81  void Image_Value_Add_Dialog();
82  void Image_Value_Add(Mat *pMA_add, QString name);
83  void Image_Value_Clear();
84 
85  void Save_ImagePlotTable();
86  void Save_Image();
87  void Save_Plot();
88  void Save_Table();
89 
90  void Calc_All();
91  void Calc_ValDistr();
92  void Calc_ImgComVal();
93  void Calc_ImgComAxeClaSta();
94  void Calc_ImgComSta();
95  void Calc_ComFea();
96  void Calc_ImgStaSta();
97  void Calc_FeaSta();
98  void Calc_StaStaSta();
99 
100  void Update_Images();
101  void Update_Image_Label();
102  void Update_Image_Value();
103  void Update_Image_Stat();
104  void Update_Image_Feature();
105 
106  void Update_Views();
107  void Update_View_Label();
108  void Update_View_Value();
109  void Update_View_Stat();
110  void Update_View_Feature();
111  void Update_View_Plot();
112 
113  void Update_Plot();
114 
115  void Plot_Pixel_Histogram();
116  void Plot_Pixel_Values_on_Axis();
117  void Plot_Pixel_ScatterValue();
118  void Plot_Pixel_ScatterHist();
119  void Plot_Pixel_ScatterAxe();
120 
121  void Plot_Comp_Feature();
122  void Plot_Comp_FeatureHist();
123  void Plot_Comp_FeatureScatter();
124  void Plot_Comp_Stat();
125  void Plot_Comp_StatHist();
126  void Plot_Comp_StatScatter();
127  void Plot_Comp_StatFeatScatter();
128 
129  void Plot_Img_Feature();
130  void Plot_Img_FeatureHist();
131  void Plot_Img_Stat();
132  void Plot_Img_StatHist();
133  void Plot_Img_StatScatter();
134  void Plot_Img_StatFeatScatter();
135 
136  void Plot_Stack_Stat();
137 
138  void Populate_CB();
139  void Populate_CB_Stats();
140  void Populate_CB_Feature();
141  void Populate_CB_ImageNames();
142  void Populate_CB_ImageNames_Single(QComboBox *CB);
143  void Populate_CB_ComponentNames();
144  void Populate_CB_ComponentNames_Single(QComboBox *CB);
145  void Populate_CB_Geometrics();
146  void Populate_CB_Geometrics_Single(QComboBox *CB);
147  void Populate_CB_Axe();
148  void Populate_CB_PlotTypes();
149  void Populate_CB_Single(QComboBox *CB, QStringList QSL);
150  void Populate_CB_PlotModePixel();
151  void Populate_CB_PlotModeComp();
152 
153  void Init_ComponentNames();
154  void Rename_Image();
155  void Rename_Component();
156 
157  void on_comboBox_ImgLab_Connectivity_currentIndexChanged(int index);
158 
159  void on_comboBox_PlotPixel_Hist_Mode_currentIndexChanged(int index);
160  void on_comboBox_PlotPixel_Axe_Mode_currentIndexChanged(int index);
161  void on_comboBox_PlotPixel_ScatterValue_Mode_currentIndexChanged(int index);
162  void on_comboBox_PlotPixel_ScatterHist_Mode_currentIndexChanged(int index);
163  void on_comboBox_PlotPixel_ScatterAxe_Mode_currentIndexChanged(int index);
164 
165  void on_comboBox_PlotComp_Stat_Mode_currentIndexChanged(int index);
166  void on_comboBox_PlotComp_StatHist_Mode_currentIndexChanged(int index);
167  void on_comboBox_PlotComp_StatScatter_Mode_currentIndexChanged(int index);
168 
169  void on_comboBox_PlotComp_StatFeatScatter_Mode_currentIndexChanged(int index);
170 
171  void on_checkBox_Plot_X_Range_clicked(bool checked);
172 
173  void on_checkBox_Plot_Y_Range_clicked(bool checked);
174 
175 private:
176  Ui::D_AnalysisWindow *ui;
177 
178  //Store
179  D_Storage *pStore;
180 
181  //Images & basic containers
182  int connectivity = 8;
183  Mat MA_Label;
184  Mat MA_Binary;
185  vector<Mat> vMA_Images;
186  vector<Mat> vMA_Images_8bit;
187  vector<D_Value_Distribution_List> v_ValDistList;
188  QStringList QSL_ImageNames;
189  QStringList QSL_ImageNames_noBinary;
190  QStringList QSL_ComponentNames;
191 
192 
193  //result images
194  Mat MA_Features;
195  Mat MA_Stats;
196 
197  //checks
198  bool b_LabelLoaded = false;
199  bool b_Calced_ValDistr = false;
200  bool b_Calced_ImgComVal = false;
201  bool b_Calced_ImgComAxeClaSta = false;
202  bool b_Calced_ImgComSta = false;
203  bool b_Calced_ComFea = false;
204  bool b_Calced_ImgStaSta = false;
205  bool b_Calced_FeaSta = false;
206  bool b_Calced_StaStaSta = false;
207 
208  //DATA
209  //pixels
210  vector<vector<vector<double>>> vvvd_ImgComVal_val;
211  vector<vector<vector<vector<vector<double>>>>> vvvvvd_ImgComAxeClaSta_val;
212  vector<vector<vector<vector<vector<double>>>>> vvvvvd_ImgComAxeStaCla_val;
213  //components
214  vector<vector<vector<double>>> vvvd_ImgComSta_val;
215  vector<vector<vector<double>>> vvvd_ImgStaCom_val;
216  vector<vector<double>> vvd_ComFea_fea;
217  vector<vector<double>> vvd_FeaCom_fea;
218  //images
219  vector<vector<vector<double>>> vvvd_ImgStaSta_val;
220  vector<vector<double>> vvd_FeaSta_fea;
221  //stack
222  vector<vector<vector<double>>> vvvd_StaStaSta_val;
223 
224 
225  //Viewer
226  D_Viewer Viewer_Image;
227 
228  //Plots
229  QChartView *pChartView_Plot;
230  void Init_Plot();
231 
232  //Table
233  D_Table Table_PlottedData;
234 
235  //Save
236  bool AutoSave = false;
237 
238  //Error handler
239  D_Error_Handler ER;
240  void ERR(int err, QString func = "not specified", QString detail = "not specified");
241 
242  //CONSTANTS
243 
244  //Image Types
245  enum IMAGE_TYPES {
246  IMAGE_LABEL,
247  IMAGE_VALUE,
248  IMAGE_FEATURE,
249  IMAGE_STATS
250  };
251 
252  //Plot Types
253  enum PLOT_TYPE_MASTER {
254  PLOT_PIXEL,
255  PLOT_COMP,
256  PLOT_IMAGE,
257  PLOT_STACK
258  };
259 
260  //Plot Pixel--------------------------------------------
261  enum PLOT_TYPE_PIXEL {
262  PLOT_PIXEL_HIST,
263  PLOT_PIXEL_AXE,
264  PLOT_PIXEL_SCATTER_VALUE,
265  PLOT_PIXEL_SCATTER_HIST,
266  PLOT_PIXEL_SCATTER_AXE
267  };
268  const QStringList QSL_PlotTypes_Pixel =
269  {
270  "Histogram of Pixel Values",
271  "Value Distribution on Axis",
272  "Compare Values",
273  "Compare Histograms",
274  "Compare Values on Axis"
275  };
276 
277  //Plot Comp Mode
278  enum PLOT_MODE_COMP {
279  PLOT_MODE_COMP_SINGLE,
280  PLOT_MODE_COMP_ALL_IMG
281  };
282  const QStringList QSL_PlotModes_Comp =
283  {
284  "Single",
285  "All Images"
286  };
287 
288  //Plot Component--------------------------------------------
289  enum PLOT_TYPE_COMP {
290  PLOT_COMP_FEAT_BAR,
291  PLOT_COMP_FEAT_HIST,
292  PLOT_COMP_FEAT_SCATTER,
293  PLOT_COMP_STAT_BAR,
294  PLOT_COMP_STAT_HIST,
295  PLOT_COMP_STAT_SCATTER,
296  PLOT_COMP_STATFEAT_SCATTER
297  };
298  const QStringList QSL_PlotTypes_Component =
299  {
300  "Features",
301  "Features Histogram",
302  "Features Compare",
303  "Statistics",
304  "Statistics Histogram",
305  "Statistics Compare",
306  "Statistics vs Feature"
307  };
308 
309  //Plot Pixel Mode
310  enum PLOT_MODE_PIXEL {
311  PLOT_MODE_PIXEL_SINGLE,
312  PLOT_MODE_PIXEL_ALL_COMP,
313  PLOT_MODE_PIXEL_ALL_IMG
314  };
315  const QStringList QSL_PlotModes_Pixel =
316  {
317  "Single",
318  "All Components",
319  "All Images"
320  };
321 
322  //Plot Image--------------------------------------------
323  enum PLOT_TYPE_IMAGE {
324  PLOT_IMAGE_FEAT,
325  PLOT_IMAGE_STAT,
326  PLOT_IMAGE_STAT_HIST,
327  PLOT_IMAGE_STAT_SCATTER
328  //PLOT_IMAGE_STATFEAT_SCATTER,
329  //PLOT_IMAGE_FEAT_HIST
330  };
331  const QStringList QSL_PlotTypes_Image =
332  {
333  "Features",
334  "Statistics",
335  "Statistics Histogram",
336  "Statistics Compare"
337  //"Statistics vs Feature"
338  //"Features Histogram",
339  };
340 
341  //Plot Stack--------------------------------------------
342  enum PLOT_TYPE_STACK {
343  PLOT_STACK_STAT
344  };
345  const QStringList QSL_PlotTypes_Stack =
346  {
347  "Statistics"
348  };
349 
350 };
351 
352 #endif // D_ANALYSISWINDOW_H
Mat
cv::Mat Mat
Definition: d_opencv_typedefs.h:28
ER_okay
@ ER_okay
Definition: d_enum.h:133
D_AnalysisWindow
The D_AnalysisWindow class GUI based custom analysis of images.
Definition: d_analysiswindow.h:68
D_Viewer::Update_View
void Update_View()
D_Viewer::Update_View Starts the workflow to show an image.
Definition: d_viewer.cpp:2096
d_component.h
D_Plot::Plot_Hist_Multi_Classes
static int Plot_Hist_Multi_Classes(QChartView *pChartView, vector< vector< double >> *vv_hist, double min_x, double max_x, double max_y, double step, QString name_title, QString name_series, QString name_x, QString name_y, bool ignore_first)
d_viewer.h
d_plot.h
D_Img_Proc::Split_img2vv_value
static int Split_img2vv_value(vector< vector< double >> *vv_data_LabPix, Mat *pMA_Value, Mat *pMA_Label, bool ignore_0)
Definition: d_img_proc.cpp:14833
D_AnalysisWindow::D_AnalysisWindow
D_AnalysisWindow(D_Storage *pStorage, QWidget *parent=0)
D_AnalysisWindow::D_AnalysisWindow Constructor.
Definition: d_analysiswindow.cpp:17
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_Table::set_data_d_1D_qs_count
void set_data_d_1D_qs_count(vector< double > v_data, QString qs_col_name)
Definition: d_table.cpp:50
D_Storage::dir_Analyzer
QDir * dir_Analyzer()
Definition: d_storage.h:77
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_Table::set_data_d_2D_qsl_count
void set_data_d_2D_qsl_count(vector< vector< double >> vv_data, QStringList qsl_col_names)
Definition: d_table.cpp:98
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
d_table.h
D_Table::Save_Table
QString Save_Table()
Definition: d_table.cpp:186
D_Viewer::Set_Transformation_Mode
void Set_Transformation_Mode(bool smooth)
D_Viewer::Set_Transformation_Mode Set transformation mode to fit an image to a viewer of different si...
Definition: d_viewer.cpp:2213
D_Table::set_data_d_2D_qsl_step
void set_data_d_2D_qsl_step(vector< vector< double >> vv_data, QStringList qsl_col_names, double row_names_start, double row_names_step)
Definition: d_table.cpp:127
D_Table::set_TW
void set_TW(QTableWidget *TW)
Definition: d_table.cpp:16
QSL_FeatureList
const QStringList QSL_FeatureList
Definition: d_enum.h:1457
D_Viewer::Save_Image_Dialog
QString Save_Image_Dialog()
D_Viewer::Save_Image_Dialog Opens a dialog to save the show image (generated default path)
Definition: d_viewer.cpp:2105
D_Img_Proc::Duplicate
static int Duplicate(Mat *pMA_Out, Mat *pMA_In)
Definition: d_img_proc.cpp:2397
D_Stat::Calc_Vector2Hist_2
static int Calc_Vector2Hist_2(vector< vector< double >> *vv_hist, vector< vector< double >> *vv_data, unsigned int class_count, double *min_ext, double *max_ext, double *max_y_ext, double *step_ext, bool accumulate, bool uniform)
Definition: d_stat.cpp:3764
D_AnalysisWindow::~D_AnalysisWindow
~D_AnalysisWindow()
D_AnalysisWindow::~D_AnalysisWindow Destructor.
Definition: d_analysiswindow.cpp:228
D_Plot::Plot_Hist_Single_Classes
static int Plot_Hist_Single_Classes(QChartView *pChartView, vector< double > *v_hist, double min, double step, QString name_title, QString name_series, QString name_x, QString name_y, bool ignore_first)
Definition: d_plot.cpp:769
D_Table::set_data_d_1D_qs_qsl
void set_data_d_1D_qs_qsl(vector< double > v_data, QString qs_col_name, QStringList qsl_row_names)
Definition: d_table.cpp:23
D_Storage::size
size_t size()
Definition: d_storage.h:57
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
ER_type_bad
@ ER_type_bad
Definition: d_enum.h:136
d_img_proc.h
D_Table
The D_Table class Display tables in QTableWidget in the user interface.
Definition: d_table.h:42
D_Viewer::set_Name
void set_Name(QString viewer_name)
Definition: d_viewer.cpp:69
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_Img_Proc::Split
static int Split(Mat *pMA_Out, Mat *pMA_In, unsigned int channel)
Definition: d_img_proc.cpp:4007
D_Plot::Plot_Scatter_2D_Multi_Y
static int Plot_Scatter_2D_Multi_Y(QChartView *pChartView, vector< double > *v_X_Val, vector< vector< double >> *vv_Y_SerVal, QString name_title, QString name_series, QString name_x, QString name_y)
D_Plot::Plot_BarCore_Multi
static int Plot_BarCore_Multi(QChartView *pChartView, vector< vector< double >> vv_data_SetVal, QString name_title, QStringList qsl_name_sets, QStringList name_categories, QString name_x, QString name_y)
Definition: d_plot.cpp:1374
ER_channel_bad
@ ER_channel_bad
Definition: d_enum.h:144
D_Plot::Plot_Scatter_2D_Multi_XY
static int Plot_Scatter_2D_Multi_XY(QChartView *pChartView, vector< vector< double >> *vv_X_SerVal, vector< vector< double >> *vv_Y_SerVal, QString name_title, QString name_series, QString name_x, QString name_y)
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_vd
void set_data_d_2D_qsl_vd(vector< vector< double >> vv_data, QStringList qsl_col_names, vector< double > v_row_names)
Definition: d_table.cpp:85
QSL_Axe
const QStringList QSL_Axe
Definition: d_enum.h:2149
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
d_analysiswindow.h
D_Table::set_data_d_1D_qs_vd
void set_data_d_1D_qs_vd(vector< double > v_data, QString qs_col_name, vector< double > v_row_names)
Definition: d_table.cpp:38
D_Plot::Plot_BarCore_Single
static int Plot_BarCore_Single(QChartView *pChartView, vector< double > v_data, QString name_title, QString name_series, QStringList name_categories, QString name_x, QString name_y)
Definition: d_plot.cpp:1333
d_component_list.h
D_Viewer::set_GV
void set_GV(QGraphicsView *GV_ui)
Definition: d_viewer.cpp:49
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.h
D_Plot::Plot_Scatter_2D_Single_Y
static int Plot_Scatter_2D_Single_Y(QChartView *pChartView, vector< double > v_X_Val, vector< double > v_Y_Val, QString name_title, QString name_series, QString name_x, QString name_y, 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:1690
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
c_GEO_CONTOUR
@ c_GEO_CONTOUR
Definition: d_enum.h:2052
D_Table::set_data_d_1D_qs_step
void set_data_d_1D_qs_step(vector< double > v_data, QString qs_col_name, double row_names_start, double row_names_step)
Definition: d_table.cpp:62
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_Viewer::Save_Image
QString Save_Image()
D_Viewer::Save_Image Saves the image at FI_LastSaved.
Definition: d_viewer.cpp:2157
D_AnalysisWindow::resizeEvent
void resizeEvent(QResizeEvent *event)
D_AnalysisWindow::resizeEvent called when window is resized and resizes the D_Viewer s.
Definition: d_analysiswindow.cpp:237
D_Img_Proc::Math_ImgScal_Div
static int Math_ImgScal_Div(Mat *pMA_Out, Mat *pMA_In, double divisor)
Definition: d_img_proc.cpp:13046
D_Table::Save_Table_Dialog
QString Save_Table_Dialog()
Definition: d_table.cpp:158
D_Img_Proc::Convert_Depth_NoScaling
static int Convert_Depth_NoScaling(Mat *pMA_Out, Mat *pMA_In, int depth)
Definition: d_img_proc.cpp:2777
D_Storage::set_dir_Analyzer
void set_dir_Analyzer(QString path)
Definition: d_storage.h:105
D_Storage::get_Adress
Mat * get_Adress(size_t pos)
Definition: d_storage.h:54
D_Stat::Calc_Vector2Hist_1
static int Calc_Vector2Hist_1(vector< double > *v_hist, vector< double > *v_data, unsigned int class_count, double *min_ext, double *max_ext, double *max_y_ext, double *step_ext, bool accumulate, bool uniform)
Definition: d_stat.cpp:3688
D_Stat::Calc_Stats
static int Calc_Stats(vector< double > *v_stats, vector< double > v_data, bool calc_sorted)
Definition: d_stat.cpp:16
c_FEAT_NUMBER_OF_FEATS
@ c_FEAT_NUMBER_OF_FEATS
Definition: d_enum.h:1455
D_Img_Proc::Draw_Label_Numbers_LUT_Gray
static int Draw_Label_Numbers_LUT_Gray(Mat *pMA_Out, Mat *pMA_In, Mat *pMA_Label, vector< double > v_LUT, int geometric, double scale, int thickness, bool center, int precision)
Definition: d_img_proc.cpp:18927
d_stat.h
ER_empty
@ ER_empty
Definition: d_enum.h:135