From 72b58a8f0b4acc801022fa844168eebef1ad80a5 Mon Sep 17 00:00:00 2001 From: tTh Date: Sat, 10 Jun 2023 08:52:36 +0200 Subject: [PATCH] add ranged RGB noise --- Modules/Makefile | 2 +- Modules/noisepictures.f90 | 26 ++++++++++++++++++++++++++ Modules/trnd.f90 | 29 ++++++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/Modules/Makefile b/Modules/Makefile index 513b113..48c4d45 100644 --- a/Modules/Makefile +++ b/Modules/Makefile @@ -6,7 +6,7 @@ GFOPT = -Wall -Wextra -g -I. -all: chkpixels t +all: chkpixels trnd t # ----------------------------------------------- diff --git a/Modules/noisepictures.f90 b/Modules/noisepictures.f90 index 4e1e10e..77fa8cc 100644 --- a/Modules/noisepictures.f90 +++ b/Modules/noisepictures.f90 @@ -75,6 +75,32 @@ subroutine noise_rgb16_pic(prgb, nbre) prgb(ix, iy)%b = mod ( irand(), 65536 ) enddo +end subroutine +!----------------------------------------------------------------------- +! new: Sat Jun 10 06:50:51 UTC 2023 + +subroutine noise_range_rgb16_pic(prgb, rngs, nbre) + implicit none + + type(t_pixrgb), dimension(:,:), intent(inout) :: prgb + integer, intent(in) :: rngs(6) + integer, intent(in) :: nbre + integer :: quux, ix, iy, width, height + + print *, 'noise rgb16 range', nbre + print *, 'ranges:' + print *, rngs + + 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 \ No newline at end of file diff --git a/Modules/trnd.f90 b/Modules/trnd.f90 index 32ad182..28f9413 100644 --- a/Modules/trnd.f90 +++ b/Modules/trnd.f90 @@ -6,12 +6,13 @@ program essai use noisepictures implicit none - integer :: foo, bar + ! integer :: foo, bar write(0, *) "----------------- essai -------------------" call init_random_seed() ! in module 'mathstuff' call test_noisepictures_rgb() + call test_noisepictures_rgb_range() call test_noisepictures_gray() contains @@ -37,6 +38,32 @@ subroutine test_noisepictures_rgb () deallocate (pix) +end subroutine +!----------------------------------------------------------------------- +! new: Sat Jun 10 06:50:51 UTC 2023 + +subroutine test_noisepictures_rgb_range () + implicit none + + type(t_pixrgb), allocatable :: pix (:,:) + integer :: nombre + integer :: ranges(6) + + print *, '------ test des noisepictures RGB range' + + allocate(pix(800, 600)) + nombre = (800*600)/4 + + call rgbpix_set_to_rgb(pix, 0, 0, 0) + ranges(1) = 0 ; ranges(2) = 21000 + ranges(3) = 22000 ; ranges(4) = 43000 + ranges(5) = 44400 ; ranges(6) = 63000 + + call noise_range_rgb16_pic(pix, ranges, nombre) + call rgbpix_spit_as_pnm_16(pix, 'rngs16.pnm') + + deallocate (pix) + end subroutine !----------------------------------------------------------------------- subroutine test_noisepictures_gray ()