[opencv] 27/251: RGB2Luv_f: R, G, B limited to [0, 1]

Nobuhiro Iwamatsu iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

iwamatsu pushed a commit to annotated tag 3.3.0
in repository opencv.

commit 6c71988c54b3531e61aa026c9df7949edf992819
Author: Rostislav Vasilikhin <rostislav.vasilikhin at intel.com>
Date:   Wed Jul 5 21:06:14 2017 +0300

    RGB2Luv_f: R, G, B limited to [0, 1]
---
 modules/imgproc/src/color.cpp | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp
index 4f27671..3c2af95 100644
--- a/modules/imgproc/src/color.cpp
+++ b/modules/imgproc/src/color.cpp
@@ -6607,6 +6607,7 @@ struct RGB2Luv_f
             for( ; i <= n - 12; i += 12, src += scn * 4 )
             {
                 float32x4x3_t v_src = vld3q_f32(src);
+
                 if( gammaTab )
                 {
                     v_src.val[0] = vmulq_f32(v_src.val[0], vdupq_n_f32(gscale));
@@ -6627,6 +6628,15 @@ struct RGB2Luv_f
             for( ; i <= n - 12; i += 12, src += scn * 4 )
             {
                 float32x4x4_t v_src = vld4q_f32(src);
+
+                v_src.val[0] = vmaxq_f32(v_src.val[0], vdupq_n_f32(0));
+                v_src.val[1] = vmaxq_f32(v_src.val[1], vdupq_n_f32(0));
+                v_src.val[2] = vmaxq_f32(v_src.val[2], vdupq_n_f32(0));
+
+                v_src.val[0] = vminq_f32(v_src.val[0], vdupq_n_f32(1));
+                v_src.val[1] = vminq_f32(v_src.val[1], vdupq_n_f32(1));
+                v_src.val[2] = vminq_f32(v_src.val[2], vdupq_n_f32(1));
+
                 if( gammaTab )
                 {
                     v_src.val[0] = vmulq_f32(v_src.val[0], vdupq_n_f32(gscale));
@@ -6670,6 +6680,20 @@ struct RGB2Luv_f
                     _mm_deinterleave_ps(v_r0, v_r1, v_g0, v_g1, v_b0, v_b1, v_a0, v_a1);
                 }
 
+                v_r0 = _mm_max_ps(v_r0, _mm_setzero_ps());
+                v_r1 = _mm_max_ps(v_r1, _mm_setzero_ps());
+                v_g0 = _mm_max_ps(v_g0, _mm_setzero_ps());
+                v_g1 = _mm_max_ps(v_g1, _mm_setzero_ps());
+                v_b0 = _mm_max_ps(v_b0, _mm_setzero_ps());
+                v_b1 = _mm_max_ps(v_b1, _mm_setzero_ps());
+
+                v_r0 = _mm_min_ps(v_r0, _mm_set1_ps(1.f));
+                v_r1 = _mm_min_ps(v_r1, _mm_set1_ps(1.f));
+                v_g0 = _mm_min_ps(v_g0, _mm_set1_ps(1.f));
+                v_g1 = _mm_min_ps(v_g1, _mm_set1_ps(1.f));
+                v_b0 = _mm_min_ps(v_b0, _mm_set1_ps(1.f));
+                v_b1 = _mm_min_ps(v_b1, _mm_set1_ps(1.f));
+
                 if ( gammaTab )
                 {
                     __m128 v_gscale = _mm_set1_ps(gscale);
@@ -6704,6 +6728,9 @@ struct RGB2Luv_f
         for( ; i < n; i += 3, src += scn )
         {
             float R = src[0], G = src[1], B = src[2];
+            R = std::min(std::max(R, 0.f), 1.f);
+            G = std::min(std::max(G, 0.f), 1.f);
+            B = std::min(std::max(B, 0.f), 1.f);
             if( gammaTab )
             {
                 R = splineInterpolate(R*gscale, gammaTab, GAMMA_TAB_SIZE);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git



More information about the debian-science-commits mailing list