#include "HalconCpp.h" int main(int argc, char *argv[]) { if (argc != 2) { cout << "Aufruf: ./aufgabe07 " << endl; return (0); } // bool-Wert fuer while-Schleife bool cont = true; // char fuer Eingabe char text_input[256]; // Lies das zu bearbeitende Bild ein: HByteImage OrigImage(argv[1]); // Öffne ein Graphikfenster: HWindow WinId; // notwendige Variablen int x, y; int height = 0; int width = 255; // Hoehe und Breite des Bildes der Variablen zuweisen height = OrigImage.Height(); width = OrigImage.Width(); // fuer Bildmanipulation HByteImage TempImage = OrigImage; // Kopie anzeigen TempImage.Display(WinId); // Hier beginnt die while-Schleife while (cont) { // Auswahl fuer den Benutzer cout << "Waehlen Sie einen der folgenden Punkte:\n"; cout << "(b)eenden\n"; cout << "(h)orizontale Kantensegmentierung\n"; cout << "(v)ertikale Kantensegmentierung\n"; cout << "(w)eichzeichnen\n\n"; cout << "Ihre Eingabe: "; // das wird dann im naechten Schritt ausgewertet cin >> text_input; // Auswertung if (!strcmp(text_input, "b")) { cout << "Das Programm wird beendet!\n"; cont = false; } else if (!strcmp(text_input, "h")) { cout << "OK, horizontale Kantensegmentierung wird durchgefuehrt.\n"; cout << "===========================================\n"; for (y = 1; y < (height - 1); y++) { for (x = 1; x < (width - 1); x++) { TempImage(x, y) = OrigImage(x, y) + ((int)(0.25 * abs(OrigImage(x - 1, y - 1) + 2 * OrigImage(x, y - 1) + OrigImage(x + 1, y + 1) - OrigImage(x + 1, y - 1) - 2 * OrigImage(x, y + 1) - OrigImage(x + 1, y + 1)))); } } // und weiter fuer iterativen Schritt cont = true; } else if (!strcmp(text_input, "v")) { cout << "OK, vertikale Kantensegmentierung wird durchgefuehrt.\n"; cout << "===========================================\n"; for (y = 1; y < (height - 1); y++) { for (x = 1; x < (width - 1); x++) { TempImage(x, y) = OrigImage(x, y) + ((int)(0.25 * abs(OrigImage(x - 1, y - 1) - OrigImage(x + 1, y - 1) + 2 * OrigImage(x - 1, y) - 2 * OrigImage(x + 1, y) + OrigImage(x - 1, y + 1) - OrigImage(x + 1, y + 1)))); } } // und weiter fuer iterativen Schritt cont = true; } else if (!strcmp(text_input, "w")) { cout << "OK, weichzeichnen des Bildes wird durchgefuehrt.\n"; cout << "===========================================\n"; for (y = 1; y < (height - 1); y++) { for (x = 1; x < (width - 1); x++) { TempImage(x,y) = (int)((1 / 9.0) * (OrigImage(x - 1, y - 1) + OrigImage(x, y - 1) + OrigImage(x + 1, y - 1) + OrigImage(x - 1, y) + OrigImage(x, y) + OrigImage(x + 1, y) + OrigImage(x - 1, y + 1) + OrigImage(x, y + 1) + OrigImage(x + 1, y + 1))); } } cont = true; } else { cout << "FEHLER: Falsche Eingabe!!\n\n"; // Irgend etwas wurde eingegeben } // TempBild dem OrigBild fuer naechste Interation zuweisen (laut Aufgabenstellung so verlangt) OrigImage = TempImage; // Manipuliertes Bild ausgeben OrigImage.Display(WinId); } // end while! return(0); }