This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new ec363d1  The order of hue composed transformation (#7756)
ec363d1 is described below

commit ec363d11689d63d02c55c6aecfa9a17b457fd5ce
Author: Yanping Huang <[email protected]>
AuthorDate: Thu Sep 7 17:15:37 2017 -0700

    The order of hue composed transformation (#7756)
    
    * The order of hue composed transformation
    
    was incorrect.
    According to https://beesbuzz.biz/code/hsv_color_transforms.php
    The final composed transform should be T_hsv  = T_rgb * T_H * T_S *  T_V * 
T_YIQ
    translating to
            t = np.dot(np.dot(self.ityiq, bt), self.tyiq).T
    
    With this correction, you can also change hue and saturation at the same 
time as  in https://beesbuzz.biz/code/hsv_color_transforms.php.
    For example:
            su = alpha_s * np.cos(alpha_h * np.pi)
            sw = alpha_s * np.sin(alpha_h * np.pi)
            bt = np.array([[alpha_v, 0.0, 0.0],
                           [0.0, su, -sw],
                           [0.0, sw, su]])
            t = np.dot(np.dot(self.ityiq, bt), self.tyiq).T
            src = nd.dot(src, nd.array(t))
            return src
    
    * vsw/vsu means v*s*w/v*s*u
    
    here only hue is changed, while v and s remain the same.
---
 python/mxnet/image/image.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/python/mxnet/image/image.py b/python/mxnet/image/image.py
index d99db21..18563cd 100644
--- a/python/mxnet/image/image.py
+++ b/python/mxnet/image/image.py
@@ -727,12 +727,12 @@ class HueJitterAug(Augmenter):
         https://beesbuzz.biz/code/hsv_color_transforms.php
         """
         alpha = random.uniform(-self.hue, self.hue)
-        vsu = np.cos(alpha * np.pi)
-        vsw = np.sin(alpha * np.pi)
+        u = np.cos(alpha * np.pi)
+        w = np.sin(alpha * np.pi)
         bt = np.array([[1.0, 0.0, 0.0],
-                       [0.0, vsu, -vsw],
-                       [0.0, vsw, vsu]])
-        t = np.dot(np.dot(self.tyiq, bt), self.ityiq).T
+                       [0.0, u, -w],
+                       [0.0, w, u]])
+        t = np.dot(np.dot(self.ityiq, bt), self.tyiq).T
         src = nd.dot(src, nd.array(t))
         return src
 

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to