; 0.4.3 RNOISE                                                     <<TIM>> DEMO
; Adds shot noise and removes it using a percentile filter
; Last Update 10 - 11 - 1990
; 07/12/92  expects image in a
;******************************************************************************
#include timdefs.h

parms
  int windisplay
endparms

int nnp
int ndiff
int rels
int phor
int pos
int diff
int err
float fres

;debug

dest p
show p
copy a			;get image
dest q
noise 1                ;produce some noise
dest s
comp q > 230
dest q
comp q < 26
inv

and p q                ;work the noise into the image
or s q
*windispl h (windisplay+WINLUT1)

era s
dest s
perc q 3               ;perform the percentile filter
*windispl i windisplay
dest r
perc q 5               ;again with a larger filter
*windispl i windisplay

era x 1                ;prepare for image text
err = chk lut 2 3
dest p
text p 1 250 99 "1. Original"
text q 1 250 70 "2. 20% shot noise"
text s 1 250 20 "3. After 2 times median filter 3x3"
text r 1 250 50 "4. After 5x5 median filter"
stop
