Skip to content

Commit

Permalink
Changed from std::sort to std::nth_element, since it is substantially…
Browse files Browse the repository at this point in the history
… faster.
  • Loading branch information
takeninenv committed Apr 9, 2024
1 parent daafea6 commit 1fd382a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cpp/FLIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -2224,9 +2224,10 @@ namespace FLIP
Ymax = std::max(luminance, Ymax);
}
}
std::sort(luminances.begin(), luminances.end());
size_t medianLocation = luminances.size() / 2 - 1;
float Ymedian = (luminances[medianLocation] + luminances[medianLocation + 1]) * 0.5f;

size_t medianLocation = luminances.size() / 2;
std::nth_element(luminances.begin(), luminances.begin() + medianLocation, luminances.end());
float Ymedian = luminances[medianLocation];

startExposure = log2(xMax / Ymax);
stopExposure = log2(xMax / Ymedian);
Expand Down

0 comments on commit 1fd382a

Please sign in to comment.