Questions tagged [bgr]

BGR is a way of encoding a color, parallel to RGB. For reasons of endian-ness, converting between BGR and RGB may sometimes be necessary.

BGR is a way of representing a color in a concise number of bits, similar to RGB. An RGB color is stored with Blue occupying the least significant "area" (e.g. a byte in 32-/24-bit formats), Green the second least, and Red the third least. A BGR color is represented in a similar way - the order of areas is reversed: Red occupies the least significant area, Green the second (still), and Blue the third. Thus, the difference between RGB and BGR is byte order.

However, many graphics libraries choose, as an implementation detail, to treat colors as unsigned 32-bit integers internally, with the three (or four when alpha is included) components packed into the integer. On a little-endian machine such as an x86 processor, the integer 0x01020304 will actually be stored in memory as 0x04030201, thus 0x00BBGGRR will be stored as 0xRRGGBB00.

The use of the term BGR (or BGRA) is a way for a graphics library to explain how the integer is logically ordered. This in turn means that code which directly accesses the color component bits can be made clearer and more readable, instead of expressing arbitrary access patterns.

70 questions
2
votes
2 answers

after merging and extracting the BGR channel, compilation is successful,but there is a run-time error: ILLEGAL OPERATION

I am trying to create 1 CV_8UC3 image from 3 different CV_8UC1 images that I already have, i.e I am trying to allocate the different single channel images that I already have into a single 1 Multi-Dimensional Image. Likely the below code worked…
indr0
  • 69
  • 1
  • 6
2
votes
1 answer

opencv - python - confused when using HSV color in cv2.inRange

I am trying to perform object detection based on the color with cv2.inRange (python 2.7). Everything seems to work fine when using BGR color. However, when I map the BGR color to HSV, I can't get a correct mask. See the example below: 1) threshold…
greg hor
  • 682
  • 6
  • 17
2
votes
1 answer

How do I read a RAW RGB image in MATLAB?

I am trying to properly convert a RAW image so that I can view it in MATLAB. Image can be downloaded here. I am using the version of the code provided in How can I read in a RAW image in MATLAB? However, it is not working properly for me. Here is my…
Anton Savelyev
  • 762
  • 7
  • 22
2
votes
1 answer

Wrong conversion from YUV to BGR using Color_YUV2BGR in opencv

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 =…
vacky
  • 277
  • 1
  • 4
  • 16
2
votes
1 answer

iOS: OpenCV Red color range

I am trying to encircle Red color in the picture using OpenCV library. I have seen many question in google but no one helped for me. My code is below: void highLightRed(const cv::Mat& inputFrame, cv::Mat& outputFrame) { cv::Mat gray, edges, red,…
Rana Ijaz
  • 458
  • 5
  • 14
1
vote
1 answer

Reading HSV value of pixel in detected circles in opencv

I have an image with detected circles and am trying to read value of these circles in HSV format. I can get the BGR values but not HSv. is there any way to convert bgr to hsv after getting bgr value or what? source code below #include…
user992520
1
vote
0 answers

Apply RGB colors to HSV one-color image

I have a HSV image( PNG ) with one color and white(transparent) background. I want to change the image's color with the following RGB values: rgb(197, 140, 133); rgb(236, 188, 180); rgb(209, 163, 164); rgb(161, 102, 94); rgb(80, 51, 53); rgb(89,…
1
vote
1 answer

Image color looks broken when being converted from BGR to HSV and back again

I have been trying to do data augmentation for image detection using deep learning framework. I'm using Opencv3.3 in Python. My framework is: Convert BGR to HSV Image transformation like (rotation, scaling, shearing, translation) Convert HSV to…
윤건우
  • 59
  • 5
1
vote
1 answer

BGR values of masked image (OpenCV, Python)

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 =…
lucians
  • 2,239
  • 5
  • 36
  • 64
1
vote
1 answer

Convert ColorSpaces using OpenCv in Python

How do I convert an image within BGRA color space to HSV and BGRA to YCbCR? I only know convertion from BGR and not BGRA. Is the approach different or the same? hsv_image = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) ycrcb_image = cv2.cvtColor(frame,…
alyssaeliyah
  • 2,214
  • 6
  • 33
  • 80
1
vote
1 answer

convert BGR to Lab without OpenCV

With little experience in color spaces, I used the following code to convert BGR image (array of unsigned characters where each channel ranges from 0 to 255) to lab color space: double F(double input) // function f(...), which is used for defining…
Hanaa Ibrahim
  • 35
  • 1
  • 6
1
vote
1 answer

How to determine whether the colour format is RGB or BGR ?

Lets assume , cgcolor = Any_UIColor.cgColor Now , how can I determine whether components of cgcolor is in RGB or BGR sequence ? (Number of components is 4) Or, UIColor will always be in R G B format ?!
roy
  • 6,685
  • 3
  • 26
  • 39
1
vote
0 answers

Colorspace reversal hiccup

I often deal with rgb->bgr issues due to PIL vs. OpenCV loading images differently. Usually I can just do orig = orig[...,::-1] but I have run into a strange hiccup down the line with that (i'm using OpenCV 3.2) ; a later function for adding some…
jeremy_rutman
  • 3,552
  • 4
  • 28
  • 47
1
vote
1 answer

Increasing Intensity when converting HSI to RGB in OpenCV using C++

Updating the question I am asking. I have successfully been able to convert from RGB to HSI and back again. I was given instruction by my professor to also increase the image intensity by adding ((1.0 - I) / 2.0) to I (intensity) before I output…
Sherd
  • 468
  • 7
  • 17
1
vote
1 answer

c# emgucv conversion of MIplImage type image from BGR color space to HSV color space

my task is to convert a program for blob tracking with kinect V1 into a program for blob tracking using Kinect v2. The first program is written in c++ and uses opencv. The new program must be write in c#, so I'm using the wrapper emgucv. The first…
Massimo P.
  • 55
  • 1
  • 10