private static void test02() //****************************************************************************80 // // Purpose: // // TEST02 tests PBMA_READ_HEADER, PBMA_READ_DATA. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 05 June 2010 // // Author: // // John Burkardt // { int[] b = null; const string file_in_name = "pbma_io_prb_02.ascii.pbm"; int k; int xsize = 0; int ysize = 0; Console.WriteLine(""); Console.WriteLine("TEST02"); Console.WriteLine(" PBMA_READ reads the header and data of an ASCII PBM file."); // // Create a data file to read. // PBMA.pbma_write_test(file_in_name); Console.WriteLine(""); Console.WriteLine(" PBMA_WRITE_TEST created some test data."); // // Now have PBMA_READ try to read it. // PBMA.pbma_read(file_in_name, ref xsize, ref ysize, ref b); Console.WriteLine(""); Console.WriteLine(" PBMA_READ was able to read the file we created."); Console.WriteLine(""); Console.WriteLine(" Sample data:"); Console.WriteLine(""); for (k = 0; k <= 29; k++) { int i = ((29 - k) * 0 + k * (xsize - 1)) / 29; int j = ((29 - k) * 0 + k * (ysize - 1)) / 29; Console.WriteLine(i.ToString().PadLeft(4) + " " + j.ToString().PadLeft(4) + " " + b[i * ysize + j].ToString().PadLeft(6) + ""); } }
private static void test01() //****************************************************************************80 // // Purpose: // // TEST01 tests PBMA_EXAMPLE, PBMA_WRITE. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 05 June 2010 // // Author: // // John Burkardt // { const string file_out_name = "pbma_io_prb_01.ascii.pbm"; const int xsize = 300; const int ysize = 300; Console.WriteLine(""); Console.WriteLine("TEST01:"); Console.WriteLine(" PBMA_EXAMPLE sets up ASCII PBM data."); Console.WriteLine(" PBMA_WRITE writes an ASCII PBM file."); Console.WriteLine(""); Console.WriteLine(" Writing the file \"" + file_out_name + "\"."); int[] b = new int[xsize * ysize]; PBMA.pbma_example(xsize, ysize, ref b); Console.WriteLine(""); Console.WriteLine(" PBMA_EXAMPLE has set up the data."); PBMA.pbma_write(file_out_name, xsize, ysize, b); Console.WriteLine(""); Console.WriteLine(" PBMA_WRITE was successful."); // // Now have PBMA_READ_TEST look at the file we think we created. // PBMA.pbma_read_test(file_out_name); Console.WriteLine(""); Console.WriteLine(" PBMA_READ_TEST was able to read the file."); }
private static void Main() //****************************************************************************80 // // Purpose: // // MAIN is the main program for IMAGE_EDGE_TEST. // // Discussion: // // IMAGE_EDGE_TEST tests the IMAGE_EDGE library. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 22 July 2011 // // Author: // // John Burkardt // { int g_max = 0; int i; const string input_filename = "coins.ascii.pgm"; string[] input_unit; int m = 0; int n = 0; const string output_filename = "coin_edges.ascii.pbm"; Console.WriteLine(""); Console.WriteLine("IMAGE_EDGE_TEST"); Console.WriteLine(" Test the IMAGE_EDGE library."); Console.WriteLine(""); Console.WriteLine(" Demonstrate the NEWS stencil for edge detection"); Console.WriteLine(" in images."); Console.WriteLine(""); Console.WriteLine(" The input file is \"" + input_filename + "\"."); try { input_unit = File.ReadAllLines(input_filename); } catch { Console.WriteLine(""); Console.WriteLine("IMAGE_EDGE_TEST - Fatal error!"); Console.WriteLine(" Could not open the file \"" + input_filename + "\""); return; } int inputIndex = 0; PGMA.pgma_read_header(input_unit, ref inputIndex, ref m, ref n, ref g_max); Console.WriteLine(""); Console.WriteLine(" Number of rows = " + m + ""); Console.WriteLine(" Number of columns = " + n + ""); Console.WriteLine(" Maximum pixel intensity = " + g_max + ""); int[] g = new int[m * n]; PGMA.pgma_read_data(input_unit, ref inputIndex, m, n, ref g); int[] g_histo = typeMethods.i4mat_histogram(m, n, g, 255); Console.WriteLine(""); Console.WriteLine(" Gray Count"); Console.WriteLine(""); for (i = 0; i <= 255; i++) { Console.WriteLine(" " + i.ToString().PadLeft(3) + " " + g_histo[i].ToString().PadLeft(8) + ""); } int[] e = NEWS.news(m, n, g); // // Write the edge information as a portable BIT map (0/1). // PBMA.pbma_write(output_filename, m, n, e); Console.WriteLine(""); Console.WriteLine(" Wrote edge information to \"" + output_filename + "\"."); // // Terminate. // Console.WriteLine(""); Console.WriteLine("IMAGE_EDGE_TEST"); Console.WriteLine(" Normal end of execution."); Console.WriteLine(""); }