         dists   (map #(.distance %) matches)
         d-min (apply min dists)
         d-max (apply max dists)
-        good (filter (fn [x] (<= (.distance x) (max (* 4.5 d-min) 0.0045))) matches)]
+        good (filter (fn [x] (<= (.distance x) (max (* 5 d-min) 0.005))) matches)]
     (dmatch-mat good)))
 
 (defn calculate-homography [img-a img-b]

        a (into-array matches)]
    (.fromArray m a)
    m))


;; ----------------------------------------------------------------



  (def iv1 [i1 i2 i3 i4 i5])
  (def iv [i2 i1])
  (def rsiv (map #(resize-to-scale % 0.25) iv))
  (def keyImage (first rsiv))
  (def col (.cols keyImage))
  (def row (.rows keyImage))

  (def keyImage (first rsiv))
  (def h (calculate-homography (first rsiv) (second rsiv)))
  (def r1 (Mat.))
  (def r2 (Mat.))
  (def r3 (Mat.))
  (def r4 (Mat.))
  (def p1 (Mat. 3 1 CvType/CV_64FC1 (Scalar. 0 0)))
  (.put p1 0 0 (double-array [0.0 0.0 1.0] ))
  (Core/gemm h p1 1  (Mat.) 0 r1 0)
  (def p2 (Mat. 3 1 CvType/CV_64FC1 (Scalar. 0 0)))
  (.put p2 0 0 (double-array [col 0.0 1.0] ))
  (Core/gemm h p2 1  (Mat.) 0 r2 0)
  (def p3 (Mat. 3 1 CvType/CV_64FC1 (Scalar. 0 0)))
  (.put p3 0 0 (double-array [0 row 1.0] ))
  (Core/gemm h p3 1  (Mat.) 0 r3 0)
  (def p4 (Mat. 3 1 CvType/CV_64FC1 (Scalar. 0 0)))
  (.put p4 0 0 (double-array [col row 1.0] ))
  (Core/gemm h p4 1  (Mat.) 0 r4 0)
  ;;(def s123456789 (reduce stitch iv1))
  ;;(write-image "test_stitches/1/s56789.jpg" s56789)

)
