From 94a5bf88d0300f4fb940afe24c723bbd50681fe7 Mon Sep 17 00:00:00 2001 From: Maria Dimashova Date: Fri, 6 May 2011 12:15:14 +0000 Subject: [PATCH] fixed #1048 --- modules/imgproc/src/grabcut.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/src/grabcut.cpp b/modules/imgproc/src/grabcut.cpp index 2cf1e453b5..e16f9da84c 100644 --- a/modules/imgproc/src/grabcut.cpp +++ b/modules/imgproc/src/grabcut.cpp @@ -260,7 +260,11 @@ double calcBeta( const Mat& img ) } } } - beta = 1.f / (2 * beta/(4*img.cols*img.rows - 3*img.cols - 3*img.rows + 2) ); + if( beta <= std::numeric_limits::epsilon() ) + beta = 0; + else + beta = 1.f / (2 * beta/(4*img.cols*img.rows - 3*img.cols - 3*img.rows + 2) ); + return beta; }