program main !*****************************************************************************80 ! !! image_denoise_test() tests image_denoise(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 27 August 2011 ! ! Author: ! ! John Burkardt ! implicit none call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'image_denoise_test():' write ( *, '(a)' ) ' Fortran90 version' write ( *, '(a)' ) ' Test image_denoise().' call test01 ( ) ! ! Terminate. ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'IMAGE_DENOISE_TEST' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) ' ' call timestamp ( ) stop 0 end subroutine test01 ( ) !*****************************************************************************80 ! !! TEST01 tests GRAY_MEDIAN_NEWS. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 27 August 2011 ! ! Author: ! ! John Burkardt ! implicit none integer, allocatable, dimension ( :, : ) :: g integer g_max integer, allocatable, dimension ( :, : ) :: g2 character ( len = 80 ) :: input_filename = "glassware_noisy.ascii.pgm" integer input_unit integer ios integer m integer n character ( len = 80 ) :: output_filename = "glassware_median_news.ascii.pgm" write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST01:' write ( *, '(a)' ) ' GRAY_MEDIAN_NEWS uses a NEWS median filter' write ( *, '(a)' ) ' on a noisy grayscale image.' 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 ) if ( ios /= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST01 - Fatal error!' write ( *, '(a)' ) ' Could not open the file "' // trim ( input_filename ) // '".' stop end if call pgma_read_header ( input_unit, m, n, g_max ) write ( *, '(a)' ) ' ' write ( *, '(a,i4)' ) ' Number of rows = ', m write ( *, '(a,i4)' ) ' Number of columns = ', n write ( *, '(a,i4)' ) ' Maximum pixel intensity = ', g_max allocate ( g(1:m,1:n) ) call pgma_read_data ( input_unit, m, n, g ); close ( unit = input_unit ) allocate ( g2(1:m,1:n) ) call gray_median_news ( m, n, g, g2 ) ! ! Write the denoised images. ! call pgma_write ( output_filename, m, n, g2 ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Wrote denoised image to "' // trim ( output_filename ) // '".' deallocate ( g ) deallocate ( g2 ) 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