comparison layer/SliceLayer.cpp @ 847:312b92ffb04e

Fix potential divide by zero
author Chris Cannam
date Wed, 03 Sep 2014 11:42:39 +0100
parents 1d526ba11a24
children 12ab113ca2b1
comparison
equal deleted inserted replaced
846:f84f1828420b 847:312b92ffb04e
394 ++divisor; 394 ++divisor;
395 } 395 }
396 396
397 float max = 0.f; 397 float max = 0.f;
398 for (int bin = 0; bin < mh; ++bin) { 398 for (int bin = 0; bin < mh; ++bin) {
399 if (m_samplingMode == SampleMean) m_values[bin] /= divisor; 399 if (m_samplingMode == SampleMean && divisor > 0) {
400 m_values[bin] /= divisor;
401 }
400 if (m_values[bin] > max) max = m_values[bin]; 402 if (m_values[bin] > max) max = m_values[bin];
401 } 403 }
402 if (max != 0.f && m_normalize) { 404 if (max != 0.f && m_normalize) {
403 for (int bin = 0; bin < mh; ++bin) { 405 for (int bin = 0; bin < mh; ++bin) {
404 m_values[bin] /= max; 406 m_values[bin] /= max;