changeset 616:76f3cb3e44ce

im2bw: threshold should be greater than only (matlab compatible)
author carandraug
date Wed, 26 Sep 2012 08:08:21 +0000
parents 8d3210ae9a4a
children 6a968d18429e
files NEWS inst/im2bw.m
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,8 @@
 
  ** `im2bw' now supports input images of the int16 class and deals better with
     RGB images since it uses `rgb2gray' internally (see changes to rgb2gray).
+    Threshold is performed on all values greater than value instead of greater
+    than or equal.
 
  ** `imhist' is much more compatible with matlab and among other changes,
     it now uses the whole range of the class for the histogram rather than
--- a/inst/im2bw.m
+++ b/inst/im2bw.m
@@ -81,8 +81,8 @@
       error("im2bw: unsupported image class");
   endswitch
 
-  BW = (img >= thres);
+  BW = (img > thres); # matlab compatible (not "greater than or equal")
 endfunction
 
-%!assert(im2bw ([0 0.5 1], 0.5), [0 1 1]);                   # basic usage
-%!assert(im2bw (uint8 ([0 120 255], 0.5)), [0 0 1]);         # with a uint8 input
+%!assert(im2bw ([0 0.4 0.5 0.6 1], 0.5), [0 0 0 1 1]);       # basic usage
+%!assert(im2bw (uint8 ([0 100 255], 0.5)), [0 0 1]);         # with a uint8 input