Fixed a potential divide by zero in draw_fhog()

This commit is contained in:
Davis King 2014-05-16 19:36:01 -04:00
parent c6d778eaf9
commit 793a8a515f
1 changed files with 8 additions and 2 deletions

View File

@ -847,7 +847,10 @@ namespace dlib
}
const double thresh = mean(himg) + 4*stddev(himg);
return matrix_cast<unsigned char>(upperbound(round(himg*255/thresh),255));
if (thresh != 0)
return matrix_cast<unsigned char>(upperbound(round(himg*255/thresh),255));
else
return matrix_cast<unsigned char>(himg);
}
// ----------------------------------------------------------------------------------------
@ -927,7 +930,10 @@ namespace dlib
}
const double thresh = mean(himg) + 4*stddev(himg);
return matrix_cast<unsigned char>(upperbound(round(himg*255/thresh),255));
if (thresh != 0)
return matrix_cast<unsigned char>(upperbound(round(himg*255/thresh),255));
else
return matrix_cast<unsigned char>(himg);
}
// ----------------------------------------------------------------------------------------