update noisepictures
This commit is contained in:
parent
c2648077f2
commit
920a864b22
@ -22,6 +22,7 @@ trigofest: trigofest.f90 Makefile vue3axes.o utils_ga.o
|
||||
|
||||
noisepic: noisepic.f90 Makefile
|
||||
gfortran $(GFOPT) $< ../Modules/spitpgm.o ../Modules/pixrgb.o \
|
||||
../Modules/noisepictures.o \
|
||||
-o $@
|
||||
|
||||
# ---- modules locaux
|
||||
|
@ -2,6 +2,7 @@ program noisepic
|
||||
|
||||
use spitpgm
|
||||
use pixrgb
|
||||
use noisepictures
|
||||
implicit none
|
||||
|
||||
integer :: numframe = 0
|
||||
@ -17,11 +18,11 @@ program noisepic
|
||||
read (arg, *) numframe
|
||||
endif
|
||||
|
||||
ranges(0) = 10 ; ranges(2) = 90
|
||||
ranges(1) = 10 ; ranges(2) = 90
|
||||
ranges(3) = 110 ; ranges(4) = 166
|
||||
ranges(5) = 205 ; ranges(6) = 230
|
||||
nbre = 1000+(numframe*555)
|
||||
call make_noise_color_range_pic(numframe, ranges, nbre)
|
||||
call make_noise_bw_pic (numframe)
|
||||
|
||||
contains
|
||||
!-- ------------------------------------------------------------------
|
||||
@ -44,33 +45,13 @@ subroutine make_noise_bw_pic (value)
|
||||
foo = irand()
|
||||
print *, 'val=', value, ' rnd=', foo
|
||||
|
||||
call plot_noise_bw_pic(pic, 15000)
|
||||
! call plot_noise_bw_pic(pic, 15000)
|
||||
call noise_gray8_pic(pic, 15000)
|
||||
|
||||
write (filename, "(a, i5.5, a)") "", value, ".pgm"
|
||||
call spit_as_pgm_8(pic, trim(filename))
|
||||
end subroutine
|
||||
!-- ------------------------------------------------------------------
|
||||
subroutine plot_noise_bw_pic(picz, nbre)
|
||||
implicit none
|
||||
|
||||
integer, dimension(:,:), intent(inout) :: picz
|
||||
integer, intent(in) :: nbre
|
||||
|
||||
integer :: width, height
|
||||
integer :: quux, ix, iy, iv
|
||||
|
||||
width = ubound(picz, 1) ; height = ubound(picz, 2)
|
||||
! print *, 'sz picz', width, height
|
||||
|
||||
do quux=1, nbre
|
||||
ix = 1 + mod ( irand(), width )
|
||||
iy = 1 + mod ( irand(), height )
|
||||
iv = mod ( irand(), 256 )
|
||||
! print *, ix, iy
|
||||
picz(ix, iy) = iv
|
||||
enddo
|
||||
end subroutine
|
||||
|
||||
!-- ------------------------------------------------------------------
|
||||
!-
|
||||
!- Colorized
|
||||
|
80
Modules/noisepictures.f90
Normal file
80
Modules/noisepictures.f90
Normal file
@ -0,0 +1,80 @@
|
||||
module noisepictures
|
||||
use pixrgb
|
||||
implicit none
|
||||
|
||||
contains ! a lot of garbage ?
|
||||
|
||||
!-----------------------------------------------------------------------
|
||||
subroutine noise_gray8_pic(pict, nbre)
|
||||
implicit none
|
||||
integer, dimension(:,:), intent(inout) :: pict
|
||||
integer, intent(in) :: nbre
|
||||
integer :: quux, ix, iy, width, height
|
||||
|
||||
width = ubound(pict, 1) ; height = ubound(pict, 2)
|
||||
|
||||
do quux=1, nbre
|
||||
ix = 1 + mod ( irand(), width )
|
||||
iy = 1 + mod ( irand(), height )
|
||||
pict(ix, iy) = mod ( irand(), 256 )
|
||||
enddo
|
||||
|
||||
end subroutine
|
||||
!-----------------------------------------------------------------------
|
||||
subroutine noise_gray16_pic(pict, nbre)
|
||||
implicit none
|
||||
integer, dimension(:,:), intent(inout) :: pict
|
||||
integer, intent(in) :: nbre
|
||||
integer :: quux, ix, iy, width, height
|
||||
|
||||
width = ubound(pict, 1) ; height = ubound(pict, 2)
|
||||
|
||||
do quux=1, nbre
|
||||
ix = 1 + mod ( irand(), width )
|
||||
iy = 1 + mod ( irand(), height )
|
||||
pict(ix, iy) = mod ( irand(), 65536 )
|
||||
enddo
|
||||
|
||||
end subroutine
|
||||
!-----------------------------------------------------------------------
|
||||
subroutine noise_rgb8_pic(prgb, nbre)
|
||||
implicit none
|
||||
type(t_pixrgb), dimension(:,:), intent(inout) :: prgb
|
||||
integer, intent(in) :: nbre
|
||||
integer :: quux, ix, iy, width, height
|
||||
|
||||
print *, 'noise_rgb_pic', nbre
|
||||
|
||||
width = ubound(prgb, 1) ; height = ubound(prgb, 2)
|
||||
|
||||
do quux=1, nbre
|
||||
ix = 1 + mod ( irand(), width )
|
||||
iy = 1 + mod ( irand(), height )
|
||||
prgb(ix, iy)%r = mod ( irand(), 256 )
|
||||
prgb(ix, iy)%g = mod ( irand(), 256 )
|
||||
prgb(ix, iy)%b = mod ( irand(), 256 )
|
||||
enddo
|
||||
|
||||
end subroutine
|
||||
!-----------------------------------------------------------------------
|
||||
subroutine noise_rgb16_pic(prgb, nbre)
|
||||
implicit none
|
||||
type(t_pixrgb), dimension(:,:), intent(inout) :: prgb
|
||||
integer, intent(in) :: nbre
|
||||
integer :: quux, ix, iy, width, height
|
||||
|
||||
print *, 'noise_rgb_pic', nbre
|
||||
|
||||
width = ubound(prgb, 1) ; height = ubound(prgb, 2)
|
||||
|
||||
do quux=1, nbre
|
||||
ix = 1 + mod ( irand(), width )
|
||||
iy = 1 + mod ( irand(), height )
|
||||
prgb(ix, iy)%r = mod ( irand(), 65536 )
|
||||
prgb(ix, iy)%g = mod ( irand(), 65536 )
|
||||
prgb(ix, iy)%b = mod ( irand(), 65536 )
|
||||
enddo
|
||||
|
||||
end subroutine
|
||||
!-----------------------------------------------------------------------
|
||||
end module noisepictures
|
@ -1,21 +1,66 @@
|
||||
program essai
|
||||
|
||||
use mathstuff2
|
||||
use pixrgb
|
||||
use spitpgm
|
||||
use noisepictures
|
||||
implicit none
|
||||
|
||||
integer :: foo, bar
|
||||
real :: quux
|
||||
double precision :: somme
|
||||
|
||||
write(0, *) "----------------- essai -------------------"
|
||||
|
||||
call init_random_seed() ! in module 'mathstuff'
|
||||
somme = 0.0
|
||||
do foo=1, 500
|
||||
quux = rand() + rand()
|
||||
somme = somme + quux
|
||||
bar = mod(irand(), 7)
|
||||
print *, foo, quux, somme/foo, bar
|
||||
enddo
|
||||
call test_noisepictures_rgb()
|
||||
call test_noisepictures_gray()
|
||||
|
||||
contains
|
||||
!-----------------------------------------------------------------------
|
||||
|
||||
subroutine test_noisepictures_rgb ()
|
||||
implicit none
|
||||
|
||||
type(t_pixrgb), allocatable :: pix (:,:)
|
||||
integer :: nombre
|
||||
print *, '------ test des noisepictures RGB'
|
||||
|
||||
allocate(pix(800, 600))
|
||||
nombre = (800*600)/4
|
||||
|
||||
call rgbpix_set_to_rgb(pix, 0, 0, 0)
|
||||
call noise_rgb8_pic(pix, nombre)
|
||||
call rgbpix_spit_as_pnm_8(pix, 'foo8.pnm')
|
||||
|
||||
call rgbpix_set_to_rgb(pix, 0, 0, 0)
|
||||
call noise_rgb16_pic(pix, nombre)
|
||||
call rgbpix_spit_as_pnm_16(pix, 'foo16.pnm')
|
||||
|
||||
deallocate (pix)
|
||||
|
||||
end subroutine
|
||||
!-----------------------------------------------------------------------
|
||||
subroutine test_noisepictures_gray ()
|
||||
implicit none
|
||||
|
||||
integer, allocatable :: pix (:,:)
|
||||
integer :: nombre
|
||||
print *, '------ test des noisepictures GRAY'
|
||||
|
||||
allocate(pix(800, 600))
|
||||
nombre = (800*600)/4
|
||||
|
||||
pix = 0
|
||||
call noise_gray8_pic(pix, nombre)
|
||||
call spit_as_pgm_8(pix, 'bar8.pgm')
|
||||
|
||||
pix = 0
|
||||
call noise_gray16_pic(pix, nombre)
|
||||
call spit_as_pgm_16(pix, 'bar16.pgm')
|
||||
|
||||
deallocate (pix)
|
||||
|
||||
end subroutine
|
||||
|
||||
!-----------------------------------------------------------------------
|
||||
|
||||
end program
|
||||
|
Loading…
Reference in New Issue
Block a user