Hough transform/Racket: Difference between revisions
m
Fixed syntax highlighting.
(=={{header|Racket}}== implementation added) |
m (Fixed syntax highlighting.) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1:
<span style='font-family: "Linux Libertine",Georgia,Times,serif;font-size:150%;'>[[Racket]]</span><hr>
{{trans|C}}
Line 19:
===Hough-transform-basic.rkt===
<
;;; Note that types are not mentioned here at all in this package
Line 80:
[(exn? (λ (x) (place-channel-put ch (cons name (exn-message x)))))]
(sub-hough-transform-channel w h trg-pxls trg-h deg-start deg-end chnl-pxls)
(place-channel-put ch (cons name #t))))</
===Hough-transform-fast.rkt===
Line 86:
Note the block:
<
(require (filtered-in
(λ (name) (regexp-replace #rx"unsafe-" name ""))
racket/unsafe/ops))
#;(require racket/flonum racket/fixnum)</
This uses unsafe, but fast, versions of <code>fx...</code> and <code>fl...</code> functions. If (especially during development and testing), one of these functions receives a non-{fix,flo}num value, then you could lose your interpreter... even DrRacket won't save you. 'Unsafe' means 'unsafe'! So until you are confident use:
<
#;(require (filtered-in
(λ (name) (regexp-replace #rx"unsafe-" name ""))
racket/unsafe/ops))
(require racket/flonum racket/fixnum)</
Racket type checks and raises exceptions against <code>fx...</code> and <code>fl...</code> functions. Once these are purged, you can remove your safety harness!
<
;;; This module tries to be a little smarter about types. It *should* prove to be better performing
Line 200:
[(exn? (λ (x) (place-channel-put ch (cons name (exn-message x)))))]
(sub-hough-transform-channel w h trg-pxls trg-h deg-start deg-end chnl-pxls)
(place-channel-put ch (cons name #t))))</
===Hough-transform.rkt===
Line 213:
(define (sub-hough-transform-channel w h trg-pxls trg-h deg-start deg-end chnl-pxls) ...)
<
;;; Derived from a port of TCL (hence the colouring of the output)
Line 329:
(transform-image "180px-Pentagon.png" "Hough-transform-basic.rkt")
(transform-image "180px-Pentagon.png" "Hough-transform-fast.rkt")
)</
|