hsv

Sorting a list of RGB triplets into a spectrum

左心房为你撑大大i 提交于 2019-12-03 15:43:46
问题 I have a list of RGB triplets, and I'd like to plot them in such a way that they form something like a spectrum. I've converted them to HSV, which people seem to recommend. from PIL import Image, ImageDraw import colorsys def make_rainbow_rgb(colors, width, height): """colors is an array of RGB tuples, with values between 0 and 255""" img = Image.new("RGBA", (width, height)) canvas = ImageDraw.Draw(img) def hsl(x): to_float = lambda x : x / 255.0 (r, g, b) = map(to_float, x) h, s, l =

tracking multiple objects by color OpenCV 2.x

折月煮酒 提交于 2019-12-03 09:12:22
Currently i am trying to track multiple objects by color. I've based on documentation code. import cv2 import numpy as np cap = cv2.VideoCapture(0) while(1): # Take each frame _, frame = cap.read() # Convert BGR to HSV hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) # define range of blue color in HSV lower_blue = np.array([110,50,50]) upper_blue = np.array([130,255,255]) # Threshold the HSV image to get only blue colors mask = cv2.inRange(hsv, lower_blue, upper_blue) # Bitwise-AND mask and original image res = cv2.bitwise_and(frame,frame, mask= mask) cv2.imshow('frame',frame) cv2.imshow('mask'

Find color name when have Hue in android

半世苍凉 提交于 2019-12-03 09:11:31
I only care about 12 colors: red: RGB: 255, 0, 0 pink: RGB: 255, 192, 203 violet: RGB: 36, 10, 64 blue: RGB: 0, 0, 255 green: RGB: 0, 255, 0 yellow: RGB: 255, 255, 0 orange: RGB: 255, 104, 31 white: RGB: 255, 255, 255 black: RGB: 0, 0, 0 gray: RGB: 128, 128, 128 tea: RGB: 193, 186, 176 cream: RGB: 255, 253, 208 When i read the pixel of bitmap, i can get the Hue value: int picw = mBitmap.getWidth(); int pich = mBitmap.getHeight(); int[] pix = new int[picw * pich]; float[] HSV = new float[3]; // get pixel array from source mBitmap.getPixels(pix, 0, picw, 0, 0, picw, pich); int index = 0; //

Sorting a list of RGB triplets into a spectrum

▼魔方 西西 提交于 2019-12-03 05:12:39
I have a list of RGB triplets, and I'd like to plot them in such a way that they form something like a spectrum. I've converted them to HSV, which people seem to recommend. from PIL import Image, ImageDraw import colorsys def make_rainbow_rgb(colors, width, height): """colors is an array of RGB tuples, with values between 0 and 255""" img = Image.new("RGBA", (width, height)) canvas = ImageDraw.Draw(img) def hsl(x): to_float = lambda x : x / 255.0 (r, g, b) = map(to_float, x) h, s, l = colorsys.rgb_to_hsv(r,g,b) h = h if 0 < h else 1 # 0 -> 1 return h, s, l rainbow = sorted(colors, key=hsl) dx

Tracking white color using python opencv

為{幸葍}努か 提交于 2019-12-03 04:04:12
问题 I would like to track white color using webcam and python opencv. I already have the code to track blue color. _, frame = cap.read() hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) # define range of blue color in HSV lower_blue = np.array([110,100,100]) upper_blue = np.array([130,255,255]) #How to define this range for white color # Threshold the HSV image to get only blue colors mask = cv2.inRange(hsv, lower_blue, upper_blue) # Bitwise-AND mask and original image res = cv2.bitwise_and(frame

From RGB to HSV in OpenGL GLSL

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to pass from RGB color space to HSV .. I searched in internet and found two different implementations, but those give me different results: A: precision mediump float; vec3 rgb2hsv(float r, float g, float b) { float h = 0.0; float s = 0.0; float v = 0.0; float min = min( min(r, g), b ); float max = max( max(r, g), b ); v = max; // v float delta = max - min; if( max != 0.0 ) s = delta / max; // s else { // r = g = b = 0 // s = 0, v is undefined s = 0.0; h = -1.0; return vec3(h, s, v); } if( r == max ) h = ( g - b ) / delta; // between

OpenCV学习笔记(5)――颜色空间转换

匿名 (未验证) 提交于 2019-12-03 00:40:02
学习如歌对图像进行颜色空间转换,从BGR到灰度图,或者从BGR到HSV等 创建一个程序用来从一幅图像中获取某个特定颜色的物体 1.转换颜色空间   OpenCV中有超过150种进行颜色空间转化的方法,但是实际上经常用到的也就两种:BGR<->Gray,BGR<->HSV   要用的函数是cv2.cvtColor(input_img,flag)flag就是转换类型   cv2.COLOR_BGR2GRAY 就是BGR<->Gray转换   cv2.COLOR_BGR2HSV 就是BGR<->HSV的转化 (介绍一下HSV格式,H指色彩/色度,取值[0,179],S是饱和度[0,255],V是亮度[0,255]。不同软件使用的值可能不同,所以当需要拿OpenCV的HSV值与别的软件的HSV值进行对比时要注意归一化) 也可以用一下代码获得所有可用的flag import cv2 flags = [i for i in dir(cv2) if i.startswith( ‘COLOR_‘)] print(flags) 2.实现物体的跟踪   在知道如何将BGR转换到HSV后,就可以利用这一点来提取带有某个特定颜色的物体。在HSV的颜色空间中要比BGR空间中个更容易表示某一个特定颜色。我们先尝试提取一个蓝色的物体,步骤如下: 从视频中获取每一帧图像 将图像转化到HSV空间

opencv颜色识别

匿名 (未验证) 提交于 2019-12-03 00:22:01
#include <imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> #include<opencv2/highgui/highgui.hpp> #include <iostream> #include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include<string> #include<vector> #define BIGGEST(a,b,c) (a>b?(a>c?a:c):(b>c?b:c)) #define RED 1 #define GREEN 2 #define BLUE 3 //HSV范围 //红色HSV范围 #define iLowH_R 125 #define iHighH_R 155 #define iLowS_R 43 #define iHighS_R 255 #define iLowV_R 46 #define iHighV_R 255 //绿色HSV范围 #define iLowH_G 35 #define iHighH_G 77 #define iLowS_G 43 #define iHighS_G 255 #define iLowV_G 46 #define iHighV_G 255 //蓝色HSV范围

RGB到HSV的彩色空间变化 Matlab

匿名 (未验证) 提交于 2019-12-03 00:20:01
clear; clc; RGB = imread('0.jpg'); HSV = rgb2hsv(RGB); H = HSV(:,:,1); S = HSV(:,:,2); V = HSV(:,:,3); R = RGB(:,:,1); G = RGB(:,:,2); B = RGB(:,:,3); subplot(4,3,1);imshow(H);title('H分量'); subplot(4,3,2);imshow(S);title('S分量'); subplot(4,3,3);imshow(V);title('V分量'); subplot(4,3,4);imhist(H);title('H分量直方图'); subplot(4,3,5);imhist(S);title('S分量直方图'); subplot(4,3,6);imhist(V);title('V分量直方图'); subplot(4,3,7);imshow(R);title('R分量'); subplot(4,3,8);imshow(G);title('G分量'); subplot(4,3,9);imshow(B);title('B分量'); subplot(4,3,10);imhist(R);title('R分量直方图'); subplot(4,3,11);imhist(G);title('G分量直方图');

iOS HSV

匿名 (未验证) 提交于 2019-12-02 23:40:02
先贴上转换公式 直接上代码 + (HSV)HSVFromRGB:(NSString *)RGB{ } 尤其要注意最后色域H值虽是0度~360度,但在iOS上是H/360.0f。 对比了很长时间,值都对,就是颜色不对,原来是因为这。