changeset 11411:b75c6b42bbc0 octave-forge

graythresh: bug fixs on concavity and intermode methods. Check that percentile is given when using percentile method.
author carandraug
date Wed, 23 Jan 2013 01:30:33 +0000
parents c20550232685
children 04d4d2b6d97b
files main/image/NEWS main/image/inst/graythresh.m
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/main/image/NEWS	Tue Jan 22 20:24:30 2013 +0000
+++ b/main/image/NEWS	Wed Jan 23 01:30:33 2013 +0000
@@ -68,6 +68,8 @@
     "triangle" method (interpolation kernel) has also been added (which is the
     same as "linear" method).
 
+ ** Bug fixes on the concavity and intermodes methods of graythresh.
+
 Summary of important user-visible changes for image 2.0.0:
 -------------------------------------------------------------------
 
--- a/main/image/inst/graythresh.m	Tue Jan 22 20:24:30 2013 +0000
+++ b/main/image/inst/graythresh.m	Wed Jan 23 01:30:33 2013 +0000
@@ -154,6 +154,8 @@
     print_usage();
   elseif (nargin > 2 && !any (strcmpi (algo, {"percentile"})))
     error ("graythresh: algorithm `%s' does not accept any options.", algo);
+  elseif (strcmpi (algo, "percentile") && (nargin != 3 || ! isscalar (varargin{1})))
+    error ("graythresh: algorithm `%s' requires a scalar value.", algo);
   else
     hist_in = false;
     ## If the image is RGB convert it to grayscale
@@ -309,7 +311,7 @@
     iter = iter+1;
     % If the histogram turns out not to be bimodal, set T to zero.
     if iter > 10000;
-      T = 0;
+      T{1} = 0;
       return
     end
   end
@@ -530,7 +532,7 @@
 endfunction
 
 function T = concavity (h)
-  n = numel (y) - 1;
+  n = numel (h) - 1;
   H = hconvhull(h);
 
   % Find the local maxima of the difference H-h.