From: <car...@us...> - 2012-09-16 22:37:08
|
Revision: 11037 http://octave.svn.sourceforge.net/octave/?rev=11037&view=rev Author: carandraug Date: 2012-09-16 22:37:02 +0000 (Sun, 16 Sep 2012) Log Message: ----------- graythresh: fix bug because intmax does not return double and wrongly named var Modified Paths: -------------- trunk/octave-forge/main/image/inst/graythresh.m Modified: trunk/octave-forge/main/image/inst/graythresh.m =================================================================== --- trunk/octave-forge/main/image/inst/graythresh.m 2012-09-16 17:47:16 UTC (rev 11036) +++ trunk/octave-forge/main/image/inst/graythresh.m 2012-09-16 22:37:02 UTC (rev 11037) @@ -99,14 +99,14 @@ endif ## If the image is RGB convert it to grayscale - if (isrgb(img)) + if (isrgb (img)) img = rgb2gray (img); endif switch tolower (algo) case {"otsu"} ## Calculation of the normalized histogram - n = intmax (class (img)) + 1; + n = double (intmax (class (img))) + 1; h = hist (img(:), 1:n); h = h / (length (img(:)) + 1); @@ -115,7 +115,7 @@ mu = zeros (n, 1); mu(1) = h(1); for i = 2:n - mu(i) = mu(i-1) + i * h(i); + mu(i) = mu(i-1) + i * h(i); endfor ## Initialisation of the values used for the threshold calculation @@ -134,12 +134,12 @@ mu0 = mu(i) / w0; mu1 = (mu(end) - mu(i)) / w1; s = w0 * w1 * (mu1 - mu0) * (mu1 - mu0); - if (s > max) + if (s > goodness) goodness = s; level = i; endif endfor - + ## Normalisation of the threshold level /= n; otherwise This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |