roy@phri.UUCP (Roy Smith) (01/13/89)
When defining a transfer function, is it important to ensure that
the result is strictly in the range of 0-1? What happens if it's not?
Here's my problem: I want to do contrant enhancement on an image with 8-bit
values (i.e. from 0-255), most of which fall in the central range. What I
want to do is pick the 10% and 90% points and stretch them to be the full
0-255 range (i.e. I'm willing to put up with clipping at the top and bottom
to get more mid-range contrast). This means that if I just do (30 is the
10% point, 185 is the 90% point, 30/255 = .1176, 255/(185-30) = 1.645):
{ 0.1176 sub 1.645 mul } settransfer
I will ocassionally return values less than 0 or greater than 1. Does
postscript automatically truncate grays to the 0-1 range or do I have to
use:
{ 0.1176 sub 1.645 mul
dup 0 lt {pop 0} if
dup 1 gt {pop 1} if
} settransfer
to ensure that the result stays within the legal range?
--
Roy Smith, System Administrator
Public Health Research Institute
{allegra,philabs,cmcl2,rutgers}!phri!roy -or- phri!roy@uunet.uu.net
"The connector is the network"
tony@oha.UUCP (Tony Olekshy) (01/14/89)
In <3648@phri.UUCP>, Roy Smith (roy@phri.UUCP) asks about settransfer: > > Does postscript automatically truncate grays to the 0-1 range...? Good Question! [Paraphrased from Gene Rayburn, Match Game '76]. I tried the following on a NEC LC-890 SilentWriter and it seems to work. Now we have a hypothesis. Anyone care to disprove it by counter-example? Yours, etc., Tony Olekshy (...!alberta!oha!tony or tony@oha.UUCP). % Cut Here ------------------------------------------------------------ 72 dup scale /x 6.5 256 div def /shade { exch /a exch def /b exch a sub 1 exch div def { a sub b mul } settransfer 1 1 256 { /i exch def i 1 sub x mul 0 moveto x 0 rlineto 0 1 rlineto x neg 0 rlineto closepath i 1 sub 255 div setgray fill } for 0 0 moveto 6.5 0 rlineto 0 1 rlineto -6.5 0 rlineto closepath 1 300 div setlinewidth 0 setgray stroke } def % shade gsave 1 9 translate 0.0 1.0 shade grestore gsave 1 8 translate 0.1 0.9 shade grestore showpage % Cut Here -------------------------------------------------------------
geof@apolling (Geof Cooper) (01/19/89)
My tests on various PostScript printers indicate that settransfer interprets numbers less than zero as zero and greater than one as one. I can confirm that UltraScript's settransfer is implemented that way. - Geof