bgr

Wrong conversion from YUV to BGR using Color_YUV2BGR in opencv

穿精又带淫゛_ 提交于 2020-01-05 02:47:27
问题 I want to convert a single set of YUV value to BGR. My code is as follows: yuv = [100, 50, 150] cv::Mat bgr_mat; cv::Mat yuv_mat(1,1,CV_8UC3,cv::Scalar(yuv[0],yuv[1],yuv[2])); cv::cvtColor(yuv_mat,bgr_mat,cv::COLOR_YUV2BGR); cv::Vec3b bgr = bgr_mat.at<cv::Vec3b>(0,0); cout << "b: " << (float)bgr.val[0] << " , g: " << (float)bgr.val[1] << " , r: " << (float)bgr.val[2] << endl; The output I get is - b: 125, g: 118, r: 0 But the expected output is b: 0, g: 112, r: 128 Can somebody please tell me

How can I know if the image is in RGB or BGR format?

岁酱吖の 提交于 2019-12-23 09:36:16
问题 Is there any way to know in advance if an image used as an input to a system is in RGB or BGR format? I am using opencv with java API and I would like to convert an input image into grayscale or L*a*b* color space, but in OpenCV you have to specify first whether the image you want to convert is in RGB or BGR. update : The type of the image I am using is either .jpg or .png 回答1: If your image is a BufferedImage then you can ask for his type with getType() , and test against the several

Converting an OpenCV BGR 8-bit Image to CIE L*a*b*

落爺英雄遲暮 提交于 2019-12-12 07:13:17
问题 I am trying to convert a given Mat representing an RGB image with 8-bit depth to Lab using the function provided in the documentation: cvtColor(source, destination, <conversion code>); I have tried the following conversion codes: CV_RGB2Lab CV_BGR2Lab CV_LBGR2Lab I have received bizarre results each time around, with an "L" value of greater than 100 for some samples, literally <107, 125, 130>. I am also using Photoshop to check the results - but given that 107 is beyond the accepted range of

BGR values of masked image (OpenCV, Python)

社会主义新天地 提交于 2019-12-11 10:12:37
问题 Using the follow image.. ... I am applying this code to create a circle mask: import cv2 import numpy as np img = cv2.imread("car.png") height, width, depth = img.shape circle_img = np.zeros((height, width), np.uint8) mask = cv2.circle(circle_img, (int(width / 2), int(height / 2)), 90, 1, thickness=-1) masked_img = cv2.bitwise_and(img, img, mask=circle_img) cv2.imshow("masked", masked_img) cv2.waitKey(0) This is the output.. How can I find BGR values of the circle using OpenCV ? 回答1: You can

python - opencv - convert pixel from bgr to hsv

蓝咒 提交于 2019-12-07 07:32:54
问题 img = cv2.imread('example.jpg') img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) # lower mask (0-10) lower_red = np.array([0, 50, 50]) upper_red = np.array([10, 255, 255] mask0 = cv2.inRange(img_hsv, lower_red, upper_red) # upper mask (170-180) lower_red = np.array([170, 50, 50]) upper_red = np.array([180, 255, 255]) mask1 = cv2.inRange(img_hsv, lower_red, upper_red) # join my masks mask = mask0 + mask1 height = mask.shape[0] width = mask.shape[1] # iterate over every pixel for i in range

python - opencv - convert pixel from bgr to hsv

微笑、不失礼 提交于 2019-12-05 11:04:47
img = cv2.imread('example.jpg') img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) # lower mask (0-10) lower_red = np.array([0, 50, 50]) upper_red = np.array([10, 255, 255] mask0 = cv2.inRange(img_hsv, lower_red, upper_red) # upper mask (170-180) lower_red = np.array([170, 50, 50]) upper_red = np.array([180, 255, 255]) mask1 = cv2.inRange(img_hsv, lower_red, upper_red) # join my masks mask = mask0 + mask1 height = mask.shape[0] width = mask.shape[1] # iterate over every pixel for i in range(height): for j in range(width): px = mask[i,j] print px # check if pixel is white or black if (px[2] >= 0

Is there a formula to determine overall color given BGR values? (OpenCV and C++)

笑着哭i 提交于 2019-11-26 16:47:40
I am making a function using C++ and OpenCV that will detect the color of a pixel in an image, determine what color range it is in, and replace it with a generic color. For example, green could range from dark green to light green, the program would determine that its still green and replace it with a simple green, making the output image very simple looking. everything is set up but I'm having trouble defining the characteristics of each range and was curious if anyone knows or a formula that, given BGR values, could determine the overall color of a pixel. If not I'll have to do much

Is there a formula to determine overall color given BGR values? (OpenCV and C++)

怎甘沉沦 提交于 2019-11-26 04:56:34
问题 I am making a function using C++ and OpenCV that will detect the color of a pixel in an image, determine what color range it is in, and replace it with a generic color. For example, green could range from dark green to light green, the program would determine that its still green and replace it with a simple green, making the output image very simple looking. everything is set up but I\'m having trouble defining the characteristics of each range and was curious if anyone knows or a formula