Calculating oCam 1CGN-U Exposure Time and Gain

Moderators: mdrjr, odroid

Calculating oCam 1CGN-U Exposure Time and Gain

Unread postby muhammadsyahyas » Wed Jan 24, 2018 6:03 pm

How to calculate Exposure (Absolute) value to seconds?
What does "Absolute" means?
I see that when the the absolute exposure decreased, the exposure time is decreased too (as result getting darker image). I really need the exact exposure time in seconds (or milisec / microsec) converted from the absolute exposure value.

And how "Gain" works? Does it multiply each pixel value with gain value (e.g. R=50 G=150 B=75, gain =2, so R'=100 G'=255(saturated) B'=150)? But I see that the gain vaue ranged from 1 to 255.

Any help would be appreciated. Thanks.
muhammadsyahyas
 
Posts: 9
Joined: Wed Jan 17, 2018 6:16 pm
languages_spoken: Bahasa Indonesia
ODROIDs: oCam 1CGN-U

Re: Calculating oCam 1CGN-U Exposure Time and Gain

Unread postby WITHROBOT » Thu Jan 25, 2018 2:45 pm

On Linux system,

Exposure(Absolute) is in 0.1 msec.
For example, Exposure(Absolute) of 100 means 100 x 0.1 msec = 10 msec.

"Gain" is the overall gain for sensor and also the gain for green color that has a value between 0 and 255.
"White Balance Red Component" is the gain for red color in % value with respect to "Gain", which has a value between 0 and 250.
"White Balance Blue Component" is the gain for blue color in % value with respect to "Gain", which has a value between 0 and 250.

In other words,
Green gain = "Gain"
Red gain = "Gain" x ("White Balance Red Component" / 100)
Blue gain = "Gain" x ("White Balance Blue Component" / 100).

For example, if "Gain" is 100, "White Balance Red Component" is 150, "White Balance Blue Component" is 200,
Green gain = 100
Red gain = 100 x (150 / 100) = 150
Blue gain = 100 x (200 / 100) = 200.
WITHROBOT
 
Posts: 136
Joined: Mon Mar 14, 2016 1:54 pm
languages_spoken: english
ODROIDs: Odroid-C2

Re: Calculating oCam 1CGN-U Exposure Time and Gain

Unread postby muhammadsyahyas » Thu Jan 25, 2018 5:09 pm

Are gains done in Bayer color space or RGB color space?

Correct me if I'm wrong, assume I have one pixel in RGB color space before "Gain" operation with components value: R = 75, G = 100, B = 125. I set Gain = 100, Red Gain = 150, Blue Gain = 50. Which one below correct?

A case :
R' = 75 + (150/100)*100 = 225
G' = 100 + 100 = 200
B' = 125 + (50/100)*100 = 175

B case :
R' = 75 * (150/100)*(100*255) = 44
G' = 100 * (100/255) = 39
B' = 125 * (50/100)*(100/255) = 24

C case (since it has default gain = 64) :
R' = 75 * (150/100)*(100*64) = 176
G' = 100 * (100/64) = 156
B' = 125 * (50/100)*(100/64) = 98

D case : another calculation?
muhammadsyahyas
 
Posts: 9
Joined: Wed Jan 17, 2018 6:16 pm
languages_spoken: Bahasa Indonesia
ODROIDs: oCam 1CGN-U

Re: Calculating oCam 1CGN-U Exposure Time and Gain

Unread postby WITHROBOT » Fri Jan 26, 2018 6:34 pm

Gains are done in Bayer color space.

Although it may be tedious, let us explain the procedure more in detail.

For oCam-1CGN-U, the value of each color is transformed in the following sequence.
Bayer RGB Sensor Data => Adjustment by Gain Settings (internally in the sensor) => Bayer to RGB Transformation (in the host system)

1. "Adjustment by Gain Settings" is carried out in Bayer color space by sensor hardware using the gain values calculated from the control values set by user in oCam_Viewer interface.
"Gain" is the overall gain for sensor and also the gain for green color that allows a user input value between 0 and 255.
"White Balance Red Component" is the gain for red color in % value with respect to "Gain", which allows a user input value between 0 and 250.
"White Balance Blue Component" is the gain for blue color in % value with respect to "Gain", which allows a user input value between 0 and 250.

In other words,
Green gain = "Gain"
Red gain = "Gain" x ("White Balance Red Component" / 100)
Blue gain = "Gain" x ("White Balance Blue Component" / 100).

For example, if "Gain" is 100, "White Balance Red Component" is 150, "White Balance Blue Component" is 200,
Green gain = 100
Red gain = 100 x (150 / 100) = 150
Blue gain = 100 x (200 / 100) = 200.

You should note that these gain values have meanings only as relative values, not as absolute values.
We do not know the internal pixel values of the sensor, but only know that the adjusted output pixel values of Bayer image sensor will have a value between 0 and 255.

2. For the "Bayer to RGB Transformation", we use the bilinear interpolation.
Refering the attached diagram, we calculate the interpolated RGB values from the sensor values in Bayer pattern.

For the pixel R33
Red = R33
Green = (G23+G32+G34+G43) / 4
Blue = (B22 + B24 + B42 + B44) / 4

For the pixel G34
Red = (R33 + R35) / 2
Green = G34
Blue = (B24 + B44) / 2

For the pixel G43
Red = (R33 + R53) / 2
Green = G43
Blue = (B42 + B44) / 2

For the pixel B44
Red = (R33 + R35 + R53 + R55) / 4
Green = (G34 + G43 + G45 + G54) / 4
Blue = B44
Attachments
Bayer Pattern.PNG
Typical Bayer Pattern
Bayer Pattern.PNG (274.83 KiB) Viewed 528 times
WITHROBOT
 
Posts: 136
Joined: Mon Mar 14, 2016 1:54 pm
languages_spoken: english
ODROIDs: Odroid-C2

Re: Calculating oCam 1CGN-U Exposure Time and Gain

Unread postby muhammadsyahyas » Mon Jan 29, 2018 5:54 pm

Thank you very much. Really helping, this is all what I need. Your answers really informative. Also I think your oCam 1CGN-U has many potentials needed to be developed :D
muhammadsyahyas
 
Posts: 9
Joined: Wed Jan 17, 2018 6:16 pm
languages_spoken: Bahasa Indonesia
ODROIDs: oCam 1CGN-U

Re: Calculating oCam 1CGN-U Exposure Time and Gain

Unread postby WITHROBOT » Tue Jan 30, 2018 9:20 am

We would very much appreciate your suggestions for improvement.
WITHROBOT
 
Posts: 136
Joined: Mon Mar 14, 2016 1:54 pm
languages_spoken: english
ODROIDs: Odroid-C2


Return to oCAM USB 3.0 Camera

Who is online

Users browsing this forum: No registered users and 3 guests