Skip to content

Commit

Permalink
bug fix chroma on filter
Browse files Browse the repository at this point in the history
  • Loading branch information
olir committed Apr 11, 2018
1 parent 347d199 commit 029da79
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugin-opencv/native/src/main/native/NativeExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ JNIEXPORT void JNICALL Java_de_serviceflow_frankenstein_plugin_opencv_jni_Native
{
int i = x * channels;

// OpenCV: For HSV, Hue range is [0,179] mapped to [0,359], Saturation range is [0,255] and Value range is [0,255].
int h = 2 * (unsigned char)rowaddr[i];
// OpenCV: For HSV, Hue range is [0,255] mapped to [0,359], Saturation range is [0,255] and Value range is [0,255].
int h = (unsigned char)rowaddr[i] * 359 / 255;
int s = (unsigned char)rowaddr[i+1];
int v = (unsigned char)rowaddr[i+2];

Expand All @@ -60,6 +60,8 @@ JNIEXPORT void JNICALL Java_de_serviceflow_frankenstein_plugin_opencv_jni_Native
int distance = keyHue - h;
if (distance<0)
distance = -distance;
if (distance>180)
distance = 360 - distance;

if (distance>=range-2)
s = s >>1;
Expand Down

0 comments on commit 029da79

Please sign in to comment.