How RBG triplet value is converted into single value? single value comes between 0 to 255. how single value is mapped into color image?

265 views Asked by At

Using OpenCV, input image(Blue background image Christmas tree inside) was read.

Below image is input image.

enter image description here

the output of read image is changed from a blue background into the red.

enter image description here

when I viewed the value of the variable of 'image' in spyder. Here 3 is RGB channel

enter image description here When double-clicked the value it shows with Axis =0. what I understood is BGR value

enter image description here

Axis =1 here to0 BGR

enter image description here

Axis =2. I am stuck here. I would not understand how triplet value of(pixel) RBG value is converted into a single value of each pixel and how this pixel(0,0)=254 represents red color here.

enter image description here

I understood for black and white values varies from 0 to 255. But here how axis =2 (pixel(0,0)=254) represents Red color(guessing from output of the read image).

1

There are 1 answers

5
Jazz On

You are reading image using OpenCV where it takes BGR color channel matrix. However you are displaying it using some other library which take color channel matrix as RGB. Convert your image to RGB using cv2.cvtColor(image, cv2.BGR2RGB) and it will then display it.