Ei kuvausta

mainwindow.h 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. // RAN 2015-07-03 - Moved some prototypes to filter.h
  2. #ifndef MAINWINDOW_H
  3. #define MAINWINDOW_H
  4. #include <QMainWindow>
  5. #include <QFileDialog>
  6. #include <QDir>
  7. #include <QMessageBox>
  8. #include <QSlider>
  9. #include <QShortcut>
  10. #include <QMessageBox>
  11. #define WHITE 0xffffffff
  12. #define BLACK 0xff000000
  13. namespace Ui {
  14. class MainWindow;
  15. }
  16. class MainWindow : public QMainWindow
  17. {
  18. Q_OBJECT
  19. public:
  20. /// \fn MainWindow::MainWindow(QWidget *parent)
  21. /// \~English
  22. /// \brief Constructor
  23. /// \~Spanish
  24. /// \brief Constructor
  25. explicit MainWindow(QWidget *parent = 0);
  26. /// \fn void MainWindow::GrayScale(QImage &editedImage)
  27. /// \~English
  28. /// \brief Function that applies a greyscale filter in the edited image.
  29. /// It works by turning each pixel into the color grey.
  30. /// \param originalImage Reference to the original image (no filter)
  31. /// \param editedImage Reference to the destination image with the filter applied.
  32. /// \~Spanish
  33. /// \brief Funcion que aplica un filtro de escala gris en la imagen editada.
  34. /// Funciona cambiando cada pixel a un tono de color gris.
  35. /// \param originalImage Referencia a la imagen original (sin filtro)
  36. /// \param editedImage Referencia a la imagen destino con el filtro aplicado.
  37. void GrayScale(QImage &);
  38. /// \fn void MainWindow::VerticalFlip(QImage &editedImage)
  39. /// \~English
  40. /// \brief Function that applies a vertical flip to the edited image.
  41. /// It works by putting the pixel from the original image in the heigth-1-j
  42. /// position of the edited image.
  43. /// \param originalImage Reference to the original image (no filter)
  44. /// \param editedImage Reference to the destination image with the filter applied.
  45. /// \~Spanish
  46. /// \brief Funcion que aplica un filtro de flip vertical en la imagen editada.
  47. /// Funciona poniendo el pixel de la imagen original en la posicion height-1-j (altura)
  48. /// de la imagen editada.
  49. /// \param editedImage Referencia a la imagen destino con el filtro aplicado.
  50. void VerticalFlip(QImage &);
  51. /// \fn void MainWindow::HorizontalFlip(QImage &editedImage)
  52. /// \~English
  53. /// \brief Function that applies a horizontal flip to the edited image.
  54. /// It works by putting the pixel from the original image in the width-1-i
  55. /// position of the edited image.
  56. /// \param originalImage Reference to the original image (no filter)
  57. /// \param editedImage Reference to the destination image with the filter applied.
  58. /// \~Spanish
  59. /// \brief Funcion que aplica un filtro de flip horizontal en la imagen editada.
  60. /// Funciona poniendo el pixel de la imagen original en la posicion width-1-i (altura)
  61. /// de la imagen editada.
  62. /// \param editedImage Referencia a la imagen destino con el filtro aplicado.
  63. void HorizontalFlip(QImage &);
  64. /// \fn void MainWindow::ThresholdFilter(QImage &originalImage, QImage &editedImage,unsigned int threshold, bool color)
  65. /// \~English
  66. /// \brief Function that applies a theshold filter to the edited image.
  67. /// It works by creating a black and white image where the color of the new pixel
  68. /// is white or black depending on a threshold value and the average of the colors
  69. /// of the pixel of the original image.
  70. /// \param originalImage Reference to the original image (no filter)
  71. /// \param editedImage Reference to the destination image with the filter applied.
  72. /// \param threshold Integer value that serves as a black or white color threshold
  73. /// \param color boolean value to select which color white or black if the color average
  74. /// is under or over the threshold.
  75. /// \~Spanish
  76. /// \brief Funcion que aplica un filtro de umbral en la imagen editada.
  77. /// Funciona creando una imagen en blanco y negro donde el color del pixel nuevo is
  78. /// blanco o negro dependiendo de un valor umbral y el promedio de los colores del pixel
  79. /// de la imagen original.
  80. /// \param originalImage Referencia a la imagen original (sin filtro)
  81. /// \param editedImage Referencia a la imagen destino con el filtro aplicado.
  82. /// \param threshold Intero que sirve como un umbral de color entre blanco y negro
  83. /// \param color Booleano para seleccionar que color blanco o negro si el promedio
  84. /// del color esta bajo o sobre el umbral.
  85. void ThresholdFilter(QImage &, QImage &,unsigned int , bool);
  86. /// \fn MainWindow::MainWindow(QWidget *parent)
  87. /// \~English
  88. /// \brief Destructor
  89. /// \~Spanish
  90. /// \brief Destructor
  91. ~MainWindow();
  92. private slots:
  93. /// \fn void MainWindow::on_actionLoad_Image_triggered()
  94. /// \~English
  95. /// \brief Invokes function on_btnLoadImage_clicked()
  96. /// \~Spanish
  97. /// \brief Invoca la funcion on_btnLoadImage_clicked()
  98. void on_actionLoad_Image_triggered();
  99. /// \fn void MainWindow::on_actionSave_Image_triggered()
  100. /// \~English
  101. /// \brief Invokes function on_btnSaveImage_clicked()
  102. /// \~Spanish
  103. /// \brief Invoca la funcion on_btnSaveImage_clicked()
  104. void on_actionSave_Image_triggered();
  105. /// \fn void MainWindow::on_actionClose_Image_triggered()
  106. /// \~English
  107. /// \brief Invokes function close()
  108. /// \~Spanish
  109. /// \brief Invoca la funcion close()
  110. void on_actionClose_Window_triggered();
  111. /// \fn void MainWindow::on_actionInvert_Threshold_Colors_triggered()
  112. /// \~English
  113. /// \brief Invokes function on_btnInvertThreshold_clicked()
  114. /// \~Spanish
  115. /// \brief Invoca la funcion on_btnInvertThreshold_clicked()
  116. void on_actionInvert_Threshold_Colors_triggered();
  117. /// \fn void MainWindow::on_actionFlip_Image_Horizontally_triggered()
  118. /// \~English
  119. /// \brief Invokes function on_btnFlipImageHorizontally_clicked()
  120. /// \~Spanish
  121. /// \brief Invoca la funcion on_btnFlipImageHorizontally_clicked()
  122. void on_actionFlip_Image_Horizontally_triggered();
  123. /// \fn void MainWindow::on_actionFlip_Image_Vertically_triggered()
  124. /// \~English
  125. /// \brief Invokes function on_btnFlipImageVertically_clicked()
  126. /// \~Spanish
  127. /// \brief Invoca la funcion on_btnFlipImageVertically_clicked()
  128. void on_actionFlip_Image_Vertically_triggered();
  129. /// \fn void MainWindow::on_actionApply_Grey_Scale_Filter_triggered()
  130. /// \~English
  131. /// \brief Invokes function on_btnGreyScaleFilter_clicked()
  132. /// \~Spanish
  133. /// \brief Invoca la funcion on_btnGreyScaleFilter_clicked()
  134. void on_actionApply_Grey_Scale_Filter_triggered();
  135. /// \fn void MainWindow::on_actionRevert_Edited_Image_to_Original_triggered()
  136. /// \~English
  137. /// \brief Invokes function on_btnRevertImage_clicked()
  138. /// \~Spanish
  139. /// \brief Invoca la funcion on_btnRevertImage_clicked()
  140. void on_actionRevert_Edited_Image_to_Original_triggered();
  141. /// \fn void MainWindow::on_actionInstructions_triggered()
  142. /// \~English
  143. /// \brief To display the instructions.
  144. /// \~Spanish
  145. /// \brief Para desplegar las instrucciones.
  146. void on_actionInstructions_triggered();
  147. /// \fn void MainWindow::applyThresholdFilter()
  148. /// \~English
  149. /// \brief To apply the threshold filter.
  150. /// \~Spanish
  151. /// \brief Para aplicar el filtro de umbral.
  152. void applyThresholdFilter();
  153. /// \fn void MainWindow::instructions()
  154. /// \~English
  155. /// \brief To display the instructions.
  156. /// \~Spanish
  157. /// \brief Para desplegar las instrucciones.
  158. void instructions();
  159. /// \fn void MainWindow::on_thresholdSlider_sliderReleased()
  160. /// \~English
  161. /// \brief To apply the threshold filter and load the edited image to the GUI when
  162. /// the GUI slider is moved.
  163. /// \~Spanish
  164. /// \brief Para aplicar el filtro de umbral y cargar la imagen editada al GUI cuando
  165. /// el deslizador del GUI es movido.
  166. void on_thresholdSlider_sliderReleased();
  167. /// \fn void MainWindow::on_btnLoadImage_clicked()
  168. /// \~English
  169. /// \brief To load an image to the GUI when the load image option is selected.
  170. /// \~Spanish
  171. /// \brief Para cargar una imagen al GUI cuando se marca opcion de cargar imagen.
  172. void on_btnLoadImage_clicked();
  173. /// \fn void MainWindow::on_btnSaveImage_clicked()
  174. /// \~English
  175. /// \brief To save an image to the file system when the save image option is selected.
  176. /// \~Spanish
  177. /// \brief Para guardar una imagen al sistema de archivos cuando se marca opcion de guardar imagen.
  178. void on_btnSaveImage_clicked();
  179. /// \fn void MainWindow::on_chboxThreshold_clicked()
  180. /// \~English
  181. /// \brief To apply the threshold filter and load the edited image to the GUI.
  182. /// \~Spanish
  183. /// \brief Para aplicar el filtro de umbral y cargar la imagen editada al GUI.
  184. void on_chboxThreshold_clicked();
  185. /// \fn void MainWindow::on_btnInvertThreshold_clicked()
  186. /// \~English
  187. /// \brief To apply the threshold filter and load the edited image to the GUI when
  188. /// the threshold color is inverted.
  189. /// \~Spanish
  190. /// \brief Para aplicar el filtro de umbral y cargar la imagen editada al GUI cuando
  191. /// el color del umbral es invertido.
  192. void on_btnInvertThreshold_clicked();
  193. /// \fn void MainWindow::on_btnFlipImageHorizontally_clicked()
  194. /// \~English
  195. /// \brief To call the horizontal flip image filter.
  196. /// \~Spanish
  197. /// \brief Para llamar al filtro de imagen flip horizontal.
  198. void on_btnFlipImageHorizontally_clicked();
  199. /// \fn void MainWindow::on_btnFlipImageVertically_clicked()
  200. /// \~English
  201. /// \brief To call the vertical flip image filter.
  202. /// \~Spanish
  203. /// \brief Para llamar al filtro de imagen flip vertical.
  204. void on_btnFlipImageVertically_clicked();
  205. /// \fn void MainWindow::on_btnGreyScaleFilter_clicked()
  206. /// \~English
  207. /// \brief To call the Gray Scale image filter.
  208. /// \~Spanish
  209. /// \brief Para llamar al filtro de imagen de escalas grises.
  210. void on_btnGreyScaleFilter_clicked();
  211. /// \fn void MainWindow::on_btnRevertImage_clicked()()
  212. /// \~English
  213. /// \brief To reset the edited image to the original image.
  214. /// \~Spanish
  215. /// \brief Para reajustar la imagen editada a la imagen original.
  216. void on_btnRevertImage_clicked();
  217. private:
  218. Ui::MainWindow *ui;
  219. QImage originalImage; //This will hold the original image.
  220. QImage editedImage; //This will hold the edited image.
  221. bool invertColor; //Boolean value of the switch button for the threshold filter.
  222. };
  223. #endif // MAINWINDOW_H