rgb

Python: Convert image from RGB to YDbDr color space

时光怂恿深爱的人放手 提交于 2020-12-13 03:27:36
问题 Trying to convert image from RGB color space to YDbDr color space according to the formula: Y = 0.299R + 0.587G + 0.114B Db = -0.45R - 0.883G +1.333B Dr = -1.333R + 1.116G + 0.217B With the following code I'm trying to show only Y channel which should be grayscale image but I keep getting image all in blue color: import numpy as np from PIL import Image import cv2 import matplotlib.pyplot as plt img = cv2.imread("./pics/Slike_modela/Test/Proba/1_Color.png") new_img = [] for row in img: new

How can I process images faster with Python?

女生的网名这么多〃 提交于 2020-12-01 10:40:46
问题 I'd trying to write a script that will detect an RGB value on the screen then click the x,y values. I know how to perform the click but I need to process the image a lot faster than my code below currently does. Is this possible with Python? So far I'm reading a row at a time, when x = 1920 I go onto the second row but it takes about 10 seconds to do one row. By that time the person on screen would have moved into a completely different spot and I have only done one row! Can I speed this code

YUV转RGB(NV21-ARGB)的Neon优化代码

柔情痞子 提交于 2020-11-27 02:42:24
说明 此代码仅限于 NV21 格式转 ARGB 格式。 NV21 格式中,Y 单独存储,UV分量交错存储。 使用如下公式: R = Y + 1.402*(V-128); G = Y - 0.34414*(U-128) - 0.71414*(V-128); B = Y + 1.772*(U-128); 浮点乘法用 6位精度处理(即a*b = ((a << 6)*b )>>6) 代码 #ifdef HAS_NEON #include <arm_neon.h> #endif void convertToRGBA( unsigned char * yuv, int w, int h, int * rgba) { for ( int i= 0 ; i<h; ++i) { unsigned char * dst = ( unsigned char *)(rgba + w*i); unsigned char * y = yuv + w*i; unsigned char * uv = yuv + w*h + w*(i/ 2 ); int count = w; #ifdef HAS_NEON /*一次处理16个像素*/ int c = count/ 16 ; asm volatile ( "mov r4, %[c]\t\n" "beq 2f\t\n" "vmov.u8 d7, #255\t\n" /

converting hex value to name of the colour in python

天涯浪子 提交于 2020-08-10 19:25:49
问题 my program outputs hex values such as (#673429ff). I wanted to convert that to the colour name. How can I get the colour name? I am using python.Here is the last part of my code: index_max = scipy.argmax(counts) # find most frequent peak = codes[index_max] colour = binascii.hexlify(bytearray(int(c) for c in peak)).decode('ascii') print('most frequent is %s (#%s)' % (peak, colour)) 回答1: Here is a solution without using existing color naming library: The code finds the best match of the picked

Printing one color using imshow [closed]

烈酒焚心 提交于 2020-08-05 05:09:12
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Improve this question I want to print a color on the screen using RGB values and the output should be just a single color. For example if I give RGB values of red, I want the output to show me a red color. But when I try this code, it isn't working. What am I missing? import matplotlib.pyplot as plt

How to get RGB components from Color SwiftUI

折月煮酒 提交于 2020-08-01 06:28:26
问题 If I have a SwiftUI Color : let col: Color = Color(red: 0.5, green: 0.5, blue: 0.5) How do I get the RGB components from col ? Like this maybe: print(col.components.red) In UIKit, I could use UIColor.getRed but there doesn't seem to be an equivalent in SwiftUI. 回答1: iOS 14 / macOS 10.16 There is a new initializer that takes a Color and returns a UIColor for iOS or NSColor for macOS now. With the help of those you can implement the following extensions: iOS / macOS import SwiftUI #if canImport