

Std::vector::iterator iterMax = std::max_element(exposureTimeLut.begin(), exposureTimeLut.end())

If(blackLevelDataNative->black_level_luts->analog_gain = maxAnalogGain)Įlse //analogGain black_level_luts->analog_gain = minAnalogGain) If (std::find(exposureTimeLut.begin(), exposureTimeLut.end(), blackLevelDataNative->black_level_luts->exposure_time) = exposureTimeLut.end())ĮxposureTimeLut.push_back(blackLevelDataNative->black_level_luts->exposure_time) if the vector does not contains the exposure, add if to the vector If(analogGain >= blackLevelDataNative->black_level_luts->analog_gain & analogGain black_level_luts->analog_gain)įor (int ch = 0 ch black_level_luts->black_level ĭouble y1 = blackLevelDataNative->black_level_luts->black_level ĭouble x0 = blackLevelDataNative->black_level_luts->analog_gain ĭouble x1 = blackLevelDataNative->black_level_luts->analog_gain find which points you need to interpolate If (analogGain >= maxAnalogGain || analogGain num_bl_luts k++) MinAnalogGain = std::min(minAnalogGain, blackLevelDataNative->black_level_luts->analog_gain) MaxAnalogGain = std::max(maxAnalogGain, blackLevelDataNative->black_level_luts->analog_gain) If (blackLevelDataNative->num_bl_luts = 1 )Īrr = blackLevelDataNative->black_level_luts->black_level ĭouble maxAnalogGain = blackLevelDataNative->black_level_luts->analog_gain ĭouble minAnalogGain = blackLevelDataNative->black_level_luts->analog_gain įor (int num = 0 num num_bl_luts num++) For any point u, given a set of (x,y) pairs with a monotonic vector x (by monotonic, I mean that x (k) < x (k+1) ), first find the index k, such that Second, perform the linear interpolation to predict the value of y at xu, between the pair of points (x (k),y (k)) and (x (k+1),y (k+1)). Matlab function output = calculateBlackLevel(blStruct, AG, ET)īlLut = zeros(length(blStruct), size(blStruct.black_level,2)) Įlseif AG > max(bl.analog_gain) || AG max(etLut) || ET exposureTimeLut
Matlab interp1 c code code#
Please comment about on the code style and correctness of my equation. I would like to convert this Black level correction function from Matlab to C++.

I don't have a strong mathematics/Matlab background.
