// IAPS - Image analysis program system // // File name : exBnd.cc // Description: an example of usage of the classes BVertexC, EdgeC, BoundaryC // Last change: 2.06.1994 // Author : Radek Marik // Libraries : iaps // ------------------------------------------------------------------ // // // Modifications: // // // #include #include #include "amma/StdType.hh" #include "amma/Pixel.hh" #include "amma/ImageRec.hh" #include "amma/Boundary.hh" #include "amma/BndRegRowIter.hh" #include "amma/ByteImag.hh" int LorErow(const EdgeC & e1, const EdgeC & e2){ if (e1.Begin().Row()<=e2.Begin().Row()) return 1; else return 0; }; int main(void) { //============== // boundary //============== cout << "An example of boundary\n" << "======================\n"; // Create the boundary of a rectangle ImageRectangleC rect(PixelC(3,3), PixelC(7,7)); BoundaryC bnd1(rect); cout << "Boundary created from the rectangle [(3,3),(7,7)]:\n" << bnd1 << '\n'; // Write into the file in compressed format ofstream os("ttt.txt"); bnd1.WriteCompressed(os); os << '\n'; os.close(); // Read from the file which boundary is in compressed format. BoundaryC bnd2; // empty boundary ifstream is("ttt.txt"); bnd2.ReadCompressed(is); is.close(); cout << "Boundary after writing and reading:\n" << bnd2 << '\n'; // Iterate over the region enclosed by the boundary BndRegRowIterC br_iter(bnd2); ByteImageC bnd_img(rect); bnd_img.Fill(0); for (br_iter.First(); br_iter.IsElm(); br_iter.Next()){ for (PixelC pxl = br_iter.Data().A(); pxl.Col() <= br_iter.Data().B().Col(); pxl.Col()++){ bnd_img[pxl] = 186; } } bnd_img.SaveAs("bnd_img.pgm"); DLIterC bnd_it(bnd2); bnd_it.Next().Next().Next().Next(); bnd_it.Del(); bnd_it.Del(); // Try the Order() routine bnd2.MergeSort(LorErow); cout << "Boundary after sorting:\n" << bnd2 << '\n'; bnd2.Order(bnd2.First()); cout << "Boundary after ordering:\n" << bnd2 << '\n'; cout << "End of the example.\n"; return(0); } // IAPS - Image analysis program system. // End of file exBnd.cc