7 Replies Latest reply on Sep 15, 2020 12:28 AM by HemanthR_06

# Losing values grayscale YUV

Hello,

I'm using an 8bit grayscale scale sensor connected to an FPGA that adds 8bit of U/V values set to 0x80 (no color).

The 16bit from the FPGA is connected to the FX3.

My firmware is based on the AN75779 example and everything works well (with my C# application or VLC player) except for one thing.

The problem is: Every software I found converts the YUV to RGB with a conversion formula like this:

`  Y -= 16;  U -= 128;  V -= 128;  R = 1.164 * Y  + 1.596 * V;  G = 1.164 * Y - 0.392 * U - 0.813 * V;  B = 1.164 * Y + 2.017 * U;`

Because my image is grayscale, U and V are zero so I get Y multiplied be 1.164.

This cases values larger then 255 (?!?!?!) and when I look at the image histogram I see values of 7, 14, 21, 28, .... are at zero in the pixel count. (6 * 1.164 = 6.984 and 7 * 1.164 = 8.148).

I want my camera to be a standard UVC camera.

How can I solve it at the firmware level?

Ofer.

• ###### 1. Re: Losing values grayscale YUV

Hi Ofer,

Since grayscale to RGB conversion requires us to make R, G and B to be same as grayscale value, can you send Y value from the FPGA as ((acual_Y_from_sensor/1.164)+16) while maintaining U and V same as 0x80?

Regards,

Hemanth

• ###### 2. Re: Losing values grayscale YUV

Hi Hemanth,

The problem will be the same but with different values (Y values can only be integers).

Can I change the GUID or some other parameter in the descriptor that will tell the application to use Y values as is?

Thank you,

Ofer.

• ###### 3. Re: Losing values grayscale YUV

Hi Ofer,

I think if the application makes conversion to grayscale(instead of rgb) from yuv2, then it takes y values as grayscale value and ignores U and V. Is this an option?

Regards,

Hemanth

• ###### 4. Re: Losing values grayscale YUV

Hi Hemanth,

The problem is I can't control the application side (like VLC for example).

I can't be the only one facing this problem.

Is there no change I can make in the descriptors that can change it?

Thanks,

Ofer.

• ###### 5. Re: Losing values grayscale YUV

Hi Ofer,

Please check if the conversion formula on the UVC host app changes according to GUID reported by the video device and if there is any suitable UVC driver-supported GUID that can be used such that Y values are taken as is.

Regards,

Hemanth

• ###### 6. Re: Losing values grayscale YUV

Hi Hemanth,

I can't find a GUID that does that.

Any suggestions?

Thanks,
Ofer.

• ###### 7. Re: Losing values grayscale YUV

Hi Ofer,

Can you please try with e-cam view player. I think you should be able to display monochrome image with the yuy2 data sent from the device. So, does monochrome display work for you?

Regards,

Hemanth