Skip to content

Commit f3627ea

Browse files
committed
* Precalculate g's value.
1 parent 0ced4c6 commit f3627ea

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

smartcrop.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ SmartCrop.prototype = {
247247
for(var x = 0; x < output.width; x++) {
248248
var p = yoffset+x*4,
249249
importance = this.importance(crop, x*downSample, ydownSample);
250-
score.skin += od[p]/255*(od[p+1]/255+options.skinBias)*importance;
251-
score.detail += od[p+1]/255*importance;
252-
score.saturation += od[p+2]/255*(od[p+1]/255*1.0+options.saturationBias)*importance;
250+
var g = od[p+1]/255;
251+
score.skin += od[p]/255*(g+options.skinBias)*importance;
252+
score.detail += g*importance;
253+
score.saturation += od[p+2]/255*(g+options.saturationBias)*importance;
253254
//if(Number.isNaN(score.detail)) debugger;
254255
//if(Number.isNaN(score.saturation)) debugger;
255256
//if(Number.isNaN(score.skin)) debugger;

0 commit comments

Comments
 (0)