No Description

Filter.cpp 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include "mainwindow.h"
  2. #include <iostream>
  3. #include <cassert>
  4. using namespace std;
  5. void messageBox(const QString &st) {
  6. QMessageBox* msgBox = new QMessageBox();
  7. msgBox->setWindowTitle("Pesky Tourist");
  8. msgBox->setText(st);
  9. msgBox->setWindowFlags(Qt::WindowStaysOnTopHint);
  10. msgBox->show();
  11. }
  12. // Given a vector of ints, sorts it in ascending order
  13. void Sort(vector<int> &V){
  14. // Implement your selection sort algorithm here
  15. }
  16. // Given a (possibly unsorted) vector of ints, returns its median
  17. int Median(vector<int> &V){
  18. // Implement your median function ...
  19. return 0;
  20. }
  21. // Given a (possibly unsorted) vector of QRgbs, returns the median
  22. // composed of the medians of the color components.
  23. QRgb MedianPixel(const vector<QRgb> &V){
  24. // Implement you pixel median function here....
  25. return qRgb(0,0,0);
  26. }
  27. void test_Sort() {
  28. // Implement your unit test for sort here .....
  29. // You may change this to a congratulatory message once you
  30. // implement this unit test :-)
  31. messageBox("Sort unit test not yet implemented!!");
  32. }
  33. void test_Median() {
  34. // Implement your unit test for median here .....
  35. messageBox("Median unit test not yet implemented!!");
  36. }
  37. void test_MedianPixel() {
  38. vector<QRgb> V;
  39. V.push_back(qRgb(10,20,30));
  40. V.push_back(qRgb(10,30,10));
  41. V.push_back(qRgb(20, 0,15));
  42. QRgb result = MedianPixel(V);
  43. assert(qRed(result) == 10);
  44. assert(qGreen(result) == 20);
  45. assert(qBlue(result) == 15);
  46. V.push_back(qRgb(0, 10,20));
  47. result = MedianPixel(V);
  48. assert(qRed(result) == 10);
  49. assert(qGreen(result) == 15);
  50. assert(qBlue(result) == 17);
  51. cout << "MedianPixel passed the test!!" << endl;
  52. }
  53. void MainWindow::RemoveNoise(const vector<QImage> & images, QImage & finalImage){
  54. // test_Sort();
  55. // test_Median();
  56. // test_MedianPixel();
  57. // Implement the filter here! See the algorithm in the lab
  58. messageBox("RemoveNoise function not yet implemented!!!");
  59. }