;+
;  IDL routine to convert a byte image to a bit image

PRO dot_plotter, image, dots

; Input:
;	image = byte image
; Output:
;	dots = byte array, either 0 or 1, same dimensions as image
;
;	Written April 1993  Barry LaBonte
;	Based on the algorithm of John Boyden and Barry LaBonte
;	Mount Wilson Observatory, 1978, for the powerful
;	Raytheon 702 and a Printronix printer.
;-

asize = SIZE(image)
dim1=asize(1)
dim2=asize(2)
dots=BYTARR(dim1,dim2)
sum = INTARR(dim1)


; Idea is to keep a running total, plot a dot and reduce the
; total when the total exceeds the maximum pixel value.
; Integrate alternate rows in opposite directions and start
; with seed from opposite side of image to break up wood
; grain pattern.

even = 2*INDGEN(dim1/2)
odd = even + 1
frac = FIX(image(*,0))
frac(even) = FIX(image(even,dim2-1))
FOR j=0,dim2-1 DO BEGIN
	up = dim2 - 1 - j
	sum(even) = FIX(image(even,j)) + frac(even)
	sum(odd) = FIX(image(odd,up)) + frac(odd)
	frac = sum MOD 255
	dots(even,j) = BYTE(sum(even)/255)
	dots(odd,up) = BYTE(sum(odd)/255)
ENDFOR

RETURN
END
