Permalink
Browse files

add map-range

  • Loading branch information...
1 parent e2a45c0 commit 87f6a29eb3f721ca6a0bd7b1bb40a29b841b1227 @nakkaya committed Dec 25, 2012
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/vision/core.clj
View
@@ -576,9 +576,11 @@
[]
(ipl-image (call :query_kinect_depth Pointer []) :bgr))
-(defn hsv-gimp-to-opencv
- "Convert HSV values from Gimp to OpenCV"
- [h s v]
- [(map-range h 0 360 0 180)
- (map-range s 0 100 0 180)
- (map-range v 0 100 0 180)])
+(let [map-range (fn [x in-min in-max out-min out-max]
+ (+ (/ (* (- x in-min) (- out-max out-min)) (- in-max in-min)) out-min))]
+ (defn hsv-gimp-to-opencv
+ "Convert HSV values from Gimp to OpenCV"
+ [h s v]
+ [(map-range h 0 360 0 180)
+ (map-range s 0 100 0 180)
+ (map-range v 0 100 0 180)]))

0 comments on commit 87f6a29

Please sign in to comment.