Ask Your Question
0

What is BGR555 in opencv?

asked 2018-05-18 09:35:38 -0600

Santhosh1 gravatar image

updated 2018-05-22 08:40:16 -0600

I got nice results with detection of brown objects in BGR555 channel 2

When I check open documentation, I could only find that cv2.COLOR_BGR2BGR55 will give a 16 bit image.

When converted it has only 2 channels

Can anyone tell me what exactly BGR555 is which contains only 2 channels?

Code

bgr555Image = cv2.cvtColor(mImage,cv2.COLOR_BGR2BGR555)
gr555Image = bgr555Image[...,1]

gLL = np.array([60])
gUL = np.array([255])

pMask = cv2.inRange(gr555Image,gLL,gUL)

This code is resulting in me detecting brown and similar colour shade objects. Can't seems to find an reason as to how?

I can't find to seem, how this values are derived in open CV this is the only link I could find. Can anyone confirm if this is the same thing used by opencv?

edit retag flag offensive close merge delete

Comments

Post your code.

sjhalayka gravatar imagesjhalayka ( 2018-05-18 18:01:45 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-05-22 08:55:48 -0600

berak gravatar image

updated 2018-05-22 09:28:10 -0600

bgr555 means: each (8bit) channel in a bgr image gets reduced to 5 bits (the lowest 3 bits get thrown away), like:

(red >> 3);

then we end up with 15 bits, which are stored in 2 8bit channels, with the high nibble in the first channel, and the low one in the 2nd.

 b1 b2 b3 b4 b5 g1 g2 g3 g4 g5 r1 r2 r3 r4 r5

 [   first channel    ] [ second channel    ]

if you use only the 2nd channel in your code, you get the lower green bits and all of the red bits, which kinda explains, why it will trigger on "brown".

also, this format is rarely used directly in computer-vision, it's more a temporary compression format (e.g. some android devices use this)

edit flag offensive delete link more

Comments

So 16bitimage in OpenCV is not https://en.wikipedia.org/wiki/High_color ?

Santhosh1 gravatar imageSanthosh1 ( 2018-05-22 09:10:40 -0600 )edit

@berak Then what's the range of the first channel and second channel here?

Santhosh1 gravatar imageSanthosh1 ( 2018-05-22 09:18:13 -0600 )edit
1

@berak I guess the documentation in OpenCV has to be changed as this is what wiki says about 16 bit images. Which is totally wrong

Santhosh1 gravatar imageSanthosh1 ( 2018-05-22 09:21:03 -0600 )edit

it's not totally wrong, but sure, misleading.

if you find a better wording here, it's easy to change it !

berak gravatar imageberak ( 2018-05-22 09:27:00 -0600 )edit

@berak16 bit images totally misleading as the term has already been coined else where.

Santhosh1 gravatar imageSanthosh1 ( 2018-05-22 10:01:05 -0600 )edit

Then what's the range of the first channel and second channel here?

uchar, [0..255]

berak gravatar imageberak ( 2018-05-22 10:04:43 -0600 )edit

first channel will contain B1 B2 B3 B4 B5 G1 G2 G3 8 bits and the second channel will contain G4 G5 R1 R2 R3 R4 R5 7 bits only? what is the 8th bit filled with in the second channel? PS: my bad the 8th bit in channel two is ignored.

Santhosh1 gravatar imageSanthosh1 ( 2018-05-23 00:22:31 -0600 )edit

@berak 1st channel range [0....255] second will be from [0....128] as the last bit/ most significant bit is ignored.

Santhosh1 gravatar imageSanthosh1 ( 2018-05-23 00:27:23 -0600 )edit

ugg, i don't know, but i'd rather expect it to be the other way round (msb ignored)

berak gravatar imageberak ( 2018-05-23 00:36:11 -0600 )edit

first channel {ignored bitB1B2B3B4B5G1G2} and second channel {G3G4G5R1R2R3R4R5} correct? so first channel [0....128] and second [0....255]

Santhosh1 gravatar imageSanthosh1 ( 2018-05-23 01:03:50 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-05-18 09:35:38 -0600

Seen: 694 times

Last updated: May 22 '18