hsv

Converting from HSV (HSB in Java) to RGB without using java.awt.Color (disallowed on Google App Engine)

自闭症网瘾萝莉.ら 提交于 2019-11-27 02:19:34
问题 I figured I should post this question, even if I have already found a solution, as a Java implementation was not readily available when I searched for it. Using HSV instead of RGB allows the generation of colors with the same saturation and brightness (something I wanted). Google App Engine does not allow use of java.awt.Color, so doing the following to convert between HSV and RGB is not an option: Color c = Color.getHSBColor(hue, saturation, value); String rgb = Integer.toHexString(c.getRGB(

Back Projection反向投影

断了今生、忘了曾经 提交于 2019-11-27 00:28:06
直方图反向投影是通过给定的直方图信息, 在原图像找到相应的像素分布区域, 其可分为基于像素点的直方图反向投影和基于区域的直方图反向投影两种方法. 经实验表明, 由于存在光照、噪声等干扰因素, 并且图像的许多特性在单一的像素级别上无法确定, 但是可从一组像素确定, 因此前者提取特征点的精度不如后者.对于归一化直方图模型来说, 反向投影图像为一幅表示目标是否可能出现的概率图, 先对图像做平滑处理, 然后寻找反向投影图像中峰值点, 并将该点在原图像中对应的位置作为目标的特征点. 对于规则目标来说, 该点即为目标的质心。 openCV提供有方便的函数,用于Back Projection,其关键函数与用法如下: 1,calcBackProject void calcBackProject( const Mat* images, int nimages, const int * channels, const SparseMat& hist, OutputArray backProject, const float ** ranges, double scale= 1 , bool uniform = true ) 2,calcHist void calcHist( const Mat* images, int nimages, const int * channels, InputArray

OpenCV Android Green Color Detection

我们两清 提交于 2019-11-26 22:55:50
currently I'm making an app where user will detect green colors. I use this photo for testing: My problem is that I can not detect any green pixel. Before I worked with blue color and everything worked fine. Now I can't detect anything though I tried different combinations of RGB . I wanted to know whether it's problem with green or my detection range, so I made an image in paint using (0, 255, 0) and it worked. Why it can't see this circle then? I use this code for detection: Core.inRange(hsv_image, new Scalar([I change this value]), new Scalar(60, 255, 255), ultimate_blue); It could have

How to change hue of a texture with GLSL?

落花浮王杯 提交于 2019-11-26 19:12:37
问题 Is there a way to efficiently change hue of a 2D OpenGL texture using GLSL (fragment shader)? Do someone have some code for it? UPDATE: This is the code resulting from user1118321 suggestion: uniform sampler2DRect texture; const mat3 rgb2yiq = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135); const mat3 yiq2rgb = mat3(1.0, 0.9563, 0.6210, 1.0, -0.2721, -0.6474, 1.0, -1.1070, 1.7046); uniform float hue; void main() { vec3 yColor = rgb2yiq * texture2DRect

RGB to HSV in PHP

戏子无情 提交于 2019-11-26 17:43:34
In PHP, what is the most straightforward way to convert a RGB triplet to HSV values? <?php function RGB_TO_HSV ($R, $G, $B) // RGB Values:Number 0-255 { // HSV Results:Number 0-1 $HSL = array(); $var_R = ($R / 255); $var_G = ($G / 255); $var_B = ($B / 255); $var_Min = min($var_R, $var_G, $var_B); $var_Max = max($var_R, $var_G, $var_B); $del_Max = $var_Max - $var_Min; $V = $var_Max; if ($del_Max == 0) { $H = 0; $S = 0; } else { $S = $del_Max / $var_Max; $del_R = ( ( ( $var_Max - $var_R ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max; $del_G = ( ( ( $var_Max - $var_G ) / 6 ) + ( $del_Max / 2 ) ) / $del

Convert HSB/HSV color to HSL

邮差的信 提交于 2019-11-26 16:45:51
问题 Ho do I convert HSB color to HSL? Photoshop shows HSB color in its color picker. HSL color can be used in CSS. I tried this JS: function hsb2hsl(h, s, b) { return { h: h, s: s, l: b-s/2 } } But hsb2hsl(0, 100, 50).l == 0 instead of 25 Update: Can I do that without converting HSB → RGB → HSL? 回答1: I'm afraid my Javascript knowledge is lacking, but you should be able to infer the conversion from http://ariya.blogspot.com/2008/07/converting-between-hsl-and-hsv.html 回答2: Let's picture what

PHP HSV to RGB formula comprehension

偶尔善良 提交于 2019-11-26 14:21:59
问题 I can convert RGB values to HSV with the following code... $r = $r/255; $g = $g/255; $b = $b/255; $h = 0; $s = 0; $v = 0; $min = min(min($r, $g),$b); $max = max(max($r, $g),$b); $r = $max-$min; $v = $max; if($r == 0){ $h = 0; $s = 0; } else { $s = $r / $max; $hr = ((($max - $r) / 6) + ($r / 2)) / $r; $hg = ((($max - $g) / 6) + ($r / 2)) / $r; $hb = ((($max - $b) / 6) + ($r / 2)) / $r; if ($r == $max) $h = $hb - $hg; else if($g == $max) $h = (1/3) + $hr - $hb; else if ($b == $max) $h = (2/3) +

Javascript convert HSB/HSV color to RGB accurately

﹥>﹥吖頭↗ 提交于 2019-11-26 11:20:54
I need to accurately convert HSB to RGB but I am not sure how to get around the problem of turning decimals into whole numbers without rounding. This is the current function I have out of a colorpicker library: HSBToRGB = function (hsb) { var rgb = { }; var h = Math.round(hsb.h); var s = Math.round(hsb.s * 255 / 100); var v = Math.round(hsb.b * 255 / 100); if (s == 0) { rgb.r = rgb.g = rgb.b = v; } else { var t1 = v; var t2 = (255 - s) * v / 255; var t3 = (t1 - t2) * (h % 60) / 60; if (h == 360) h = 0; if (h < 60) { rgb.r = t1; rgb.b = t2; rgb.g = t2 + t3 } else if (h < 120) { rgb.g = t1; rgb

OpenCV Android Green Color Detection

别来无恙 提交于 2019-11-26 08:26:43
问题 currently I\'m making an app where user will detect green colors. I use this photo for testing: My problem is that I can not detect any green pixel. Before I worked with blue color and everything worked fine. Now I can\'t detect anything though I tried different combinations of RGB . I wanted to know whether it\'s problem with green or my detection range, so I made an image in paint using (0, 255, 0) and it worked. Why it can\'t see this circle then? I use this code for detection: Core

How to change RGB color to HSV?

China☆狼群 提交于 2019-11-26 07:39:57
How to change RGB color to HSV? In C# language. I search for very fast method without any external library. georged Have you considered simply using System.Drawing namespace? For example: System.Drawing.Color color = System.Drawing.Color.FromArgb(red, green, blue); float hue = color.GetHue(); float saturation = color.GetSaturation(); float lightness = color.GetBrightness(); Note that it's not exactly what you've asked for (see differences between HSL and HSV and the Color class does not have a conversion back from HSL/HSV but the latter is reasonably easy to add . Note that Color.GetSaturation