diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 9480d8a60..4bdc4e68e 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -673,11 +673,20 @@ fclose(f);*/ ave /= (sum); //find median of luminance - int median=0, count=0; + int median=0, count=histogram[0]; while (countlog(imax+1)/log2(2)) { @@ -713,6 +731,16 @@ fclose(f);*/ ospread += (octile[i+1]-octile[i])/max(0.5f,(i>2 ? (octile[i+1]-octile[3]) : (octile[3]-octile[i]))); } ospread /= 5; + if (ospread<=0) {//probably the image is a blackframe + expcomp=0; + black=0; + bright=0; + contr=0; + hlcompr=0; + hlcomprthresh=0; + return; + } + // compute clipping points based on the original histograms (linear, without exp comp.) int clipped = 0; @@ -747,7 +775,7 @@ fclose(f);*/ shc <<= histcompr; //prevent division by 0 - if (ave==0) ave=1; + if (ave<1) return; if (lodev==0) lodev=1; //compute exposure compensation as geometric mean of the amount that