Compare commits

...

3 Commits

Author SHA1 Message Date
tTh 920a864b22 update noisepictures 2023-06-09 23:59:54 +02:00
tTh c2648077f2 make a .a file 2023-06-09 21:35:01 +02:00
tTh db7091d5c4 bloub? 2023-06-06 12:22:56 +02:00
6 changed files with 163 additions and 43 deletions

View File

@ -21,7 +21,8 @@ trigofest: trigofest.f90 Makefile vue3axes.o utils_ga.o
utils_ga.o -o $@
noisepic: noisepic.f90 Makefile
gfortran $(GFOPT) $< ../Modules/spitpgm.o ../Modules/pixrgb.o \
gfortran $(GFOPT) $< ../Modules/spitpgm.o ../Modules/pixrgb.o \
../Modules/noisepictures.o \
-o $@
# ---- modules locaux

View File

@ -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

View File

@ -28,17 +28,30 @@ trials.o: trials.f90 Makefile
mathstuff2.o: mathstuff2.f90 Makefile
gfortran $(GFOPT) -c $<
noisepictures.o: noisepictures.f90 Makefile
gfortran $(GFOPT) -c $<
#
# making a fluffy archive
#
OBJECTS = spitpgm.o pixrgb.o \
centermag.o dummy.o \
trials.o mathstuff2.o \
noisepictures.o
libtth90modules.a: $(OBJECTS) Makefile
$(AR) rs $@ $?
#
# programmes de testouille
#
OBJS = trials.o spitpgm.o pixrgb.o centermag.o dummy.o \
mathstuff2.o
chkpixels: chkpixels.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
chkpixels: chkpixels.f90 Makefile libtth90modules.a
gfortran $(GFOPT) $< libtth90modules.a -o $@
t: t.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
t: t.f90 Makefile libtth90modules.a
gfortran $(GFOPT) $< libtth90modules.a -o $@
trnd: trnd.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
trnd: trnd.f90 Makefile libtth90modules.a
gfortran $(GFOPT) $< libtth90modules.a -o $@

View File

@ -22,7 +22,7 @@ module mathstuff2
! after initializing the random generator engine,
! you MUST use it for initializing the initializer
do foo=1, tarray(1)+5
do foo=1, tarray(1)+15
dummy = rand()
enddo

80
Modules/noisepictures.f90 Normal file
View 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

View File

@ -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