dre1980
Posts: 2
Joined: Sun Nov 03, 2013 7:55 pm

color depth

What is the highest color depth I can get from the camera board.
I would like to get:
Y = 8-bits
U = 8-bits
V = 8-bits
My current code is getting:
Y = 8-bits
U = 2-bits
V = 2-bits

jamesh
Raspberry Pi Engineer & Forum Moderator
Posts: 25464
Joined: Sat Jul 30, 2011 7:41 pm

Re: color depth

YUV420.

So 8 bits for Y, but subsampled U and V at 8 bit. (so one 8 bit value defines 4 pixels worth of U and V), so your 2 bits UV is a bit misleading - you've simply divided out the size by the pixels, missing out the subsampling.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

dre1980
Posts: 2
Joined: Sun Nov 03, 2013 7:55 pm

Re: color depth

Thanks I think I now get it.

My understanding is that there is 4 Y pixels that share 1 byte for U and 1 byte for V.

Is there any way to resize one of these frames so that there is 1 byte for Y and 1 byte for U and 1 byte for V.
If so, is there a name for this?

jamesh
Raspberry Pi Engineer & Forum Moderator
Posts: 25464
Joined: Sat Jul 30, 2011 7:41 pm

Re: color depth

dre1980 wrote:Thanks I think I now get it.

My understanding is that there is 4 Y pixels that share 1 byte for U and 1 byte for V.

Is there any way to resize one of these frames so that there is 1 byte for Y and 1 byte for U and 1 byte for V.
If so, is there a name for this?
Just write some image conversion code that does that - pretty simple. Get the buffer, create a destination buffer, copy from one to the other undo the subsampling. Or you can get RGB out from the camera ISP which is RGB888 IIRC.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

wibble82
Posts: 66
Joined: Sun Jan 27, 2013 5:06 pm
Contact: Website

Re: color depth

Hi

I'd recommend getting the RGB data out - the YUV420 format can be a little confusing - I found the buffer positions can be oddly aligned for some image sizes. If you want to get back to YUV from RGB there's a fairly simple algorithm to do it. This page goes over them:

http://www.fourcc.org/fccyvrgb.php

What are you using to extract the image?

-Chris

jamesh
Raspberry Pi Engineer & Forum Moderator
Posts: 25464
Joined: Sat Jul 30, 2011 7:41 pm

Re: color depth

The alignment is standard for all YUV (and I think RGB)- widths and plane heights must be divisible by 16, so are padded to those values.

So if your height is not %16=0, there will be padding between the Y plane and the U plane, similar between U and V. If width is %16!=0 then there will be padding bytes at the end of each line to make it %16=0.

This is to improve RAM accesses by the VPU which works best at 16 byte boundaries (it's a 16 way SIMD unit)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

sharix
Posts: 200
Joined: Thu Feb 16, 2012 11:29 am
Location: Slovenia

Re: color depth

I assume this is directly connected to this bug

jamesh
Raspberry Pi Engineer & Forum Moderator
Posts: 25464
Joined: Sat Jul 30, 2011 7:41 pm

Re: color depth

sharix wrote:I assume this is directly connected to this bug
yup.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."