christer@zeus.cs.umu.se (Christer Ericson) (05/22/89)
I would like to add some random noice to the grayscale when I'm filling an area. I have tried to do something like this (simplified example); 60 45 { add rand 3 mod add 1 sub 3.0 div } setscreen but obviously the current screen is only accessed once before the filling and not during the operation (as I would want it to work). Is there any way to accomplish this in a straightforward way? Thanks, /Christer | Christer Ericson Internet: christer@cs.umu.se | | Department of Computer Science, University of Umea, S-90187 UMEA, Sweden | | >>>>> "I bully sheep. I claim God doesn't exist..." <<<<< |
geof@apolling (Geof Cooper) (05/24/89)
In article <861@umecs.cs.umu.se> christer@zeus.UUCP (Christer Ericson) writes: >I would like to add some random noice to the grayscale when I'm filling an >area. I have tried to do something like this (simplified example); > > 60 45 { add rand 3 mod add 1 sub 3.0 div } setscreen > >but obviously the current screen is only accessed once before the filling and >not during the operation (as I would want it to work). No simple way. PostScript uses an imaging model that calls for a particular type of half-tone screen. It is not willing to half-tone using other digital techniques, such as convolution with random screens, etc.. As for adding random noise to the image, the only way that I can think of to do this is to generate the image, then superimpose a noise function on top of it. The noise function is just a "repeat" loop that turns a bit on or off at a random location (hopefully within the image). Here is some non-debugged code that illustrates the technique. I would expect this to take a LONG time to work for any real amount of noise. % SizeX and SizeY are the dimensions of the image that has % been imaged at the current origin. % The current origin should be pixel aligned using: % 0 0 moveto currentpoint transform round exch round itransform translate /xpix 1 0 idtransform dup mul exch dup mul add sqrt def /ypix 0 1 idtransform dup mul exch dup mul add sqrt def /SizeX SizeX xpix div round def /SizeY SizeY ypix div round def xpix ypix scale /sr { rand 2.15e9 div } bind def 1000 { sr SizeX mul round sr SizeY mul round moveto rand 16#4000000 ge {0}{1}ifelse setgray 0 1 rlineto 1 0 rlineto 0 -1 rlineto fill } bind repeat