program main !*****************************************************************************80 ! !! image_edge_test() tests image_edge(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 26 December 2010 ! ! Author: ! ! John Burkardt ! implicit none call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'image_edge_test():' write ( *, '(a)' ) ' Fortran90 version' write ( *, '(a)' ) ' Test image_edge().' call test01 ( 'coins.ascii.pgm', 'coin_edges.ascii.pbm' ) call test01 ( 'pepper.ascii.pgm', 'pepper_edges.ascii.pbm' ) ! ! Terminate. ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'IMAGE_EDGE_TEST' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) ' ' call timestamp ( ) stop 0 end subroutine test01 ( input_filename, output_filename ) !*****************************************************************************80 ! !! MAIN is the main program for NEWS_PRB. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 05 June 2010 ! ! Author: ! ! John Burkardt ! implicit none integer, allocatable :: e(:,:) integer, allocatable :: g(:,:) integer g_histo(0:255) integer g_max integer i character ( len = * ) input_filename integer input_unit integer ios integer m integer n character ( len = * ) output_filename write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' The input file is "' // trim ( input_filename ) // '"' ! ! Open the input file and read the data. ! call get_unit ( input_unit ) open ( unit = input_unit, file = input_filename, status = 'old', & iostat = ios ) call pgma_read_header ( input_unit, m, n, g_max ) write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Number of rows = ', m write ( *, '(a,i8)' ) ' Number of columns = ', n write ( *, '(a,i8)' ) ' Maximum pixel intensity = ', g_max allocate ( g(1:m,1:n) ) call pgma_read_data ( input_unit, m, n, g ) close ( unit = input_unit ) call i4mat_histogram ( m, n, g, 255, g_histo ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Gray Count' write ( *, '(a)' ) ' ' do i = 0, 255 write ( *, '(2x,i3,2x,i8)' ) i, g_histo(i) end do allocate ( e(1:m,1:n) ) call news ( m, n, g, e ) ! ! Write the Edge information as a portable BIT map (0/1). ! call pbma_write ( output_filename, m, n, e ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Wrote edge information to "' & // trim ( output_filename ) // '".' deallocate ( e ) deallocate ( g ) return end subroutine timestamp ( ) !*****************************************************************************80 ! !! TIMESTAMP prints the current YMDHMS date as a time stamp. ! ! Example: ! ! 31 May 2001 9:45:54.872 AM ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 May 2013 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! None ! implicit none character ( len = 8 ) ampm integer d integer h integer m integer mm character ( len = 9 ), parameter, dimension(12) :: month = (/ & 'January ', 'February ', 'March ', 'April ', & 'May ', 'June ', 'July ', 'August ', & 'September', 'October ', 'November ', 'December ' /) integer n integer s integer values(8) integer y call date_and_time ( values = values ) y = values(1) m = values(2) d = values(3) h = values(5) n = values(6) s = values(7) mm = values(8) if ( h < 12 ) then ampm = 'AM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Noon' else ampm = 'PM' end if else h = h - 12 if ( h < 12 ) then ampm = 'PM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Midnight' else ampm = 'AM' end if end if end if write ( *, '(i2,1x,a,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) & d, trim ( month(m) ), y, h, ':', n, ':', s, '.', mm, trim ( ampm ) return end