#lang scheme/base
(require
"../tools.ss"
"gnuplot.ss"
"image-io.ss"
"hough.ss"
)
(define (sobel i)
(define ^2 (U (lambda (x) (* x x))))
((B +)
(^2 ((X -) i))
(^2 ((Y -) i))))
(define (thresh t)
(U (lambda (x) (if (> x t) 255 0))))
(define (pgm-gen dir)
(generator
(lambda (yield)
(parameterize ((current-directory dir))
(for/list ((file (directory-list)))
(yield (load-pgm file)))))))
(define (pgm-sequence->raw dir file)
(with-output-to-file file
(lambda ()
(parameterize ((current-directory dir))
(for ((file (directory-list)))
(write-image (load-pgm file)))))
#:exists 'replace))
(define img (pgm-gen "/home/tom/LFSR/seq1"))
(define play (make-yuv4mpeg-process "yuvplay" "-s" "512x384"))
(define (test)
(for ((pgm (in-generator img)))
(play pgm)))
(define i (img))
(define hough
(hough-transform #:r-bins 100 #:max-r 800
#:angle-bins 100 #:max-angle (atan 1)))
(define (seq-max seq)
(let ((max 0))
(for ((s seq))
(when (> s max) (set! max s)))
max))
(define (compress img)
(let* ((max (seq-max (image-data img)))
(scale (/ 255 max)))
((U (lambda (x)
(inexact->exact
(floor (* x scale)))))
img)))