Path: utzoo!attcan!uunet!husc6!endor!olson
From: olson@endor.harvard.edu (Eric K. Olson)
Newsgroups: comp.lang.postscript
Subject: Re: Screening Procedures
Keywords: PostScript random halftone screen
Message-ID: <4885@husc6.harvard.edu>
Date: 5 Jul 88 14:11:56 GMT
References: <174@chip.UUCP>  <248@oha.UUCP>
Sender: news@husc6.harvard.edu
Reply-To: olson@endor.UUCP (Eric K. Olson)
Organization: Lexington Software Design, Lexington, MA
Lines: 59

In a recent article Tony Olekshy writes:
>sg1q+@andrew.cmu.edu (Simon Peter Gatrall) writes:
>>
>> I've been interested in playing with the procedures PostScript uses to do
>> halftoning, and I was wondering if anyone else is familiar with this stuff. 
>> One thing that bothers me is that once a pattern is made to represent a
>> specific gray value, it isn't recomputed.  This makes all the sense in the
>> world for line and dot screens, but what if you want something that looks
>> like a texture?
>
>Here, here!  The following code will generate a random-patterned grey scale
>with the probability of any pixel being white being proportional to the grey
>level:
>
>	1 45 { pop pop rand 1073741824 div 1 sub } setscreen
>
>The problem is that when you use this, the maximum area that gets patterned
>is 0.1" x 0.1", and THAT pattern is replicated over the whole area being
>painted.  CAN halftoning be used to randomly pattern the entire area being
>painted?
>

As far as I know, there's no way to specify a screen in PostScript for which
the pattern for weight n>m does not include all of the pattern for weight m.
For instance, dots are possible ({ dup mul exch dup mul add 1 exch sub}),
but circles are not.  This is due to the way the screen is specified (at least
in part), as a function of x and y.  Chances are that PostScript internally
stores the _order_ of turning on the pixels in the pattern, and not the
patterns themselves.

However, it should be possible to write an ordered dither screen function
(I don't know how useful it would be at 300 dpi, though), since it conforms
to the limitation above.

Some other fun screens:

Horizontal Lines:	{exch pop abs 1 exch sub}
Crosses:		{dup mul exch dup mul mul 1 exch sub}
Diamonds:		{abs exch abs add 2 div} 
BowTies:		{mul}
Lines & Dots:		{dup dup mul mul exch dup dup mul mul
			 add abs 1 exch sub} 

Note that these are named for their appearance at 0 degree rotation:
diamonds are squares at 45 degrees, for instance.

Also, since PostScript picks randomly among pixels returning the same
ordering value, I believe you can get a random texture screen via
{pop pop 1} (i.e., a function returning the same value all the time).
This, of course, doesn't work any better than the random screen
suggested above.

-Eric


          Lexington Software Design:  Tomorrow's Software Yesterday

Eric K. Olson     olson@endor.harvard.edu     harvard!endor!olson     D0760
   (Name)                (ArpaNet)                 (UseNet)        (AppleLink)