rgb

Python | Numpy array images transformations

与世无争的帅哥 提交于 2021-02-05 08:43:05
问题 I have a Numpy image array with shape (1000, 50, 100, 3) ( class 'numpy.ndarray' ) which is containing 1000 images RGB (height = 50, width = 100, channels = 3). I want to first convert the RGB values to YUV values and rescale them to obtain yuv values. A prototypical implementation of a pixel-wise converter is given below. My question : Is there a simple way how I can carry out this transformation? def yuv(_pixel): R, G, B = _pixel[0], _pixel[1], _pixel[2] Y = 0.299 * R + 0.587 * G + 0.114 *

Python | Numpy array images transformations

柔情痞子 提交于 2021-02-05 08:43:00
问题 I have a Numpy image array with shape (1000, 50, 100, 3) ( class 'numpy.ndarray' ) which is containing 1000 images RGB (height = 50, width = 100, channels = 3). I want to first convert the RGB values to YUV values and rescale them to obtain yuv values. A prototypical implementation of a pixel-wise converter is given below. My question : Is there a simple way how I can carry out this transformation? def yuv(_pixel): R, G, B = _pixel[0], _pixel[1], _pixel[2] Y = 0.299 * R + 0.587 * G + 0.114 *

Convert RGB Color to HEX color

。_饼干妹妹 提交于 2021-01-29 11:05:35
问题 I am taking a color from an ImageView using OnTouchListener . Red, Green, Blue color code can be successfully obtained, but i cant convert RGB to HEX .. example : my rgb values are r:21 b:16 g:228 and curresponding hex color is #15e410. i want get #15e410. from r:21 ,b:16 ,g:228 int pixel = bitmap.getPixel(x,y); int redValue = Color.red(pixel); int blueValue = Color.blue(pixel); int greenValue = Color.green(pixel); int hexa= Color.rgb(redValue, greenValue, blueValue); Toast.makeText

RGB to HSV in numpy

偶尔善良 提交于 2021-01-29 06:44:51
问题 I'm trying to implement RGB to HSV conversion from opencv in pure numpy using formula from here: def rgb2hsv_opencv(img_rgb): img_hsv = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2HSV) return img_hsv def rgb2hsv_np(img_rgb): assert img_rgb.dtype == np.float32 height, width, c = img_rgb.shape r, g, b = img_rgb[:,:,0], img_rgb[:,:,1], img_rgb[:,:,2] t = np.min(img_rgb, axis=-1) v = np.max(img_rgb, axis=-1) s = (v - t) / (v + 1e-6) s[v==0] = 0 # v==r hr = 60 * (g - b) / (v - t + 1e-6) # v==g hg = 120 +

OpenCV with RGB 16bits

本小妞迷上赌 提交于 2021-01-28 16:25:12
问题 I have a data (unsigned char*) with RGB 16 bits format R:5 G:6 B:5 How can I set this data to IplImage format? I can start with: unsigned char* data = ...data...; IplImage *img = cvCreateImage(cvSize(800,480), IPL_DEPTH_8U, 3); // Should it be 16? cvSetData(img,data,800*2); // Here is where I am not sure 回答1: You are going to need to convert from IPL_DEPTH_16U (single-channel) to IPL_DEPTH_8U (three-channel). Below is some code I wrote up quickly (this should work, but I don't have a 565

How to store Colors in string?

喜欢而已 提交于 2021-01-27 07:38:57
问题 I want to store Color in string if they are Human Readable format and ToArgb() if they are not. Color is Red then store it in "Red" string and If color is say some variant of green then it is store as "ff40ff80". At runtime I want to convert this strings back to Color class Object? 回答1: You're in luck. The Color.ToString() method will do this for you: Return Value Type: System.String A string that is the name of this Color, if the Color is created from a predefined color by using either the

Conversion formula from RGB to YCbCr

不羁岁月 提交于 2021-01-21 08:04:22
问题 Whats the real conversion formula for this because I found so many ways on how to convert I don't know which one is real From wikipedia: From microsoft https://msdn.microsoft.com/en-us/library/ff635643.aspx : and microsoft is the same with this conversion site http://www.equasys.de/colorconversion.html: Can anybody explain the difference of the formula? 回答1: If it still actual they are almost the same. Differences are what value ranges you'll get in the result. From Wiki's matrix (R',G',B' =

Conversion formula from RGB to YCbCr

大憨熊 提交于 2021-01-21 08:04:10
问题 Whats the real conversion formula for this because I found so many ways on how to convert I don't know which one is real From wikipedia: From microsoft https://msdn.microsoft.com/en-us/library/ff635643.aspx : and microsoft is the same with this conversion site http://www.equasys.de/colorconversion.html: Can anybody explain the difference of the formula? 回答1: If it still actual they are almost the same. Differences are what value ranges you'll get in the result. From Wiki's matrix (R',G',B' =

How to change rgb values from a png image with libpng using c?

心已入冬 提交于 2021-01-04 04:22:14
问题 What is a recommendable way to change the rgb values of a png image? Right now I'm using an example code to see the way libpng works, it only opens a png image and writes another png image, however I would like to change the RGB values of this new image so that it gets to be all blue, green or red, whatever is my choice, is there an efficient way to do it? Code: #include <stdlib.h> #include <stdio.h> #include <png.h> int width, height; png_byte color_type; png_byte bit_depth; png_bytep *row

How to change rgb values from a png image with libpng using c?

余生颓废 提交于 2021-01-04 04:21:14
问题 What is a recommendable way to change the rgb values of a png image? Right now I'm using an example code to see the way libpng works, it only opens a png image and writes another png image, however I would like to change the RGB values of this new image so that it gets to be all blue, green or red, whatever is my choice, is there an efficient way to do it? Code: #include <stdlib.h> #include <stdio.h> #include <png.h> int width, height; png_byte color_type; png_byte bit_depth; png_bytep *row