
! script name: plot.d/scnaimage

!A
!A NAME:
!A
!A 	Scan image and create contour
!A
!A DESCRIPTION:
!A
!A	Sets parameters for taking a scanned image from the clipboard and
!A	finds a connected set of pixels greater than a minimum length.
!A	Also does noise reduction and pixel thickening functions.
!A
!B INSTRUCTIONS:
!B
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: scan image")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]

Start:!

Stat= SetEqualsValue(150)
Stat= SetInputFormat("n0=","")
Resolution=GetValue("PIXELS PER INCH",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat= SetEqualsValue(50)
Stat= SetInputFormat("n0=","")
Minlen=GetValue("MINIMUM CONTOUR LENGTH IN PIXELS",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat= SetEqualsValue(5)
Stat= SetInputFormat("n0=","")
Minpix=GetValue("MINIMUM PIXEL GROUP SIZE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetEqualsValue(10)
Stat= SetInputFormat("n0=","")
Nattempts=GetValue("NUMBER OF ATTEMPTS TO FIND CONTOUR",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetEqualsValue(1)
Stat= SetInputFormat("n0=","")
Thick=GetValue("PIXEL THICKNESS",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetScanParameters("/tmp/synscan",Resolution, Minlen, Minpix, Nattempts, Thick)

Leave:!
Stat= SetInputFormat("n4","")

IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
