@@ -259,6 +259,69 @@ std::vector<std::vector<LuminanceInfo>> splitMonotonics(const std::vector<Lumina
259
259
return splitted;
260
260
}
261
261
262
+ // Check the specific case of 2 items per group without outlier
263
+ if (luminanceInfos.size () % 2 == 0 )
264
+ {
265
+ float exp0 = luminanceInfos[0 ].mexposure ;
266
+ float exp1 = luminanceInfos[1 ].mexposure ;
267
+ if (exp0 != exp1)
268
+ {
269
+ int idx = 2 ;
270
+ bool ok = true ;
271
+ while (ok && idx < luminanceInfos.size ())
272
+ {
273
+ ok = ok && luminanceInfos[idx].mexposure == exp0 && luminanceInfos[idx+1 ].mexposure == exp1;
274
+ idx += 2 ;
275
+ }
276
+ if (idx == luminanceInfos.size ())
277
+ {
278
+ std::vector<LuminanceInfo> current;
279
+ for (int i = 0 ; i < luminanceInfos.size (); i++)
280
+ {
281
+ current.push_back (luminanceInfos[i]);
282
+ if (i % 2 == 1 )
283
+ {
284
+ splitted.push_back (current);
285
+ current.clear ();
286
+ }
287
+ }
288
+ return splitted;
289
+ }
290
+ }
291
+ }
292
+
293
+ // Check the corner case of 3 items per group ordered with middle exposure first and without outlier
294
+ if (luminanceInfos.size () % 3 == 0 )
295
+ {
296
+ float exp0 = luminanceInfos[0 ].mexposure ;
297
+ float exp1 = luminanceInfos[1 ].mexposure ;
298
+ float exp2 = luminanceInfos[2 ].mexposure ;
299
+ if (exp0 > exp1 && exp0 < exp2 || exp0 < exp1 && exp0 > exp2 )
300
+ {
301
+ int idx = 3 ;
302
+ bool ok = true ;
303
+ while (ok && idx < luminanceInfos.size ())
304
+ {
305
+ ok = ok && luminanceInfos[idx].mexposure == exp0 && luminanceInfos[idx+1 ].mexposure == exp1 && luminanceInfos[idx+2 ].mexposure == exp2 ;
306
+ idx += 3 ;
307
+ }
308
+ if (idx == luminanceInfos.size ())
309
+ {
310
+ std::vector<LuminanceInfo> current;
311
+ for (int i = 0 ; i < luminanceInfos.size (); i++)
312
+ {
313
+ current.push_back (luminanceInfos[i]);
314
+ if (i % 3 == 2 )
315
+ {
316
+ splitted.push_back (current);
317
+ current.clear ();
318
+ }
319
+ }
320
+ return splitted;
321
+ }
322
+ }
323
+ }
324
+
262
325
// Split the luminanceInfos into groups which have monotonic values
263
326
// (either increasing or decreasing)
264
327
std::vector<LuminanceInfo> current;
0 commit comments