gigasquid commented on a change in pull request #13813: [WIP] examples with 
opencv4/origami
URL: https://github.com/apache/incubator-mxnet/pull/13813#discussion_r247347927
 
 

 ##########
 File path: contrib/clojure-package/examples/gan/src/gan/viz.clj
 ##########
 @@ -37,29 +32,11 @@
        (mapv #(.byteValue %))))
 
 (defn get-img [raw-data channels height width flip]
-  (let [totals (* height width)
-        img (if (> channels 1)
-              ;; rgb image
-              (let [[ra ga ba] (byte-array (partition totals raw-data))
-                    rr (new Mat height width (CvType/CV_8U))
-                    gg (new Mat height width (CvType/CV_8U))
-                    bb (new Mat height width (CvType/CV_8U))
-                    result (new Mat)]
-                (.put rr (int 0) (int 0) ra)
-                (.put gg (int 0) (int 0) ga)
-                (.put bb (int 0) (int 0) ba)
-                (Core/merge (java.util.ArrayList. [bb gg rr]) result)
-                result)
+  (let [img (if (> channels 1)
+              (throw (Exception. "Image with 3 channels (RGB) not supported"))
               ;; gray image
-              (let [result (new Mat height width (CvType/CV_8U))
-                    _ (.put result (int 0) (int 0) (byte-array raw-data))]
-                result))]
-    (do
-      (if flip
-        (let [result (new Mat)
-              _ (Core/flip img result (int 0))]
-          result)
-        img))))
+              (cv/>> (new-mat height width CV_8UC1) (byte-array raw-data)))]
 
 Review comment:
   neat threading :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to