changeset 11263:23cc50443349 octave-forge

imhist: adjust y axis for outliers
author carandraug
date Fri, 23 Nov 2012 00:09:27 +0000
parents 0f3d40c65d4a
children 7131a4bb7ce7
files main/image/NEWS main/image/inst/imhist.m
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/main/image/NEWS	Thu Nov 22 23:13:14 2012 +0000
+++ b/main/image/NEWS	Fri Nov 23 00:09:27 2012 +0000
@@ -4,7 +4,8 @@
  ** The plot produced by `imhist' is correctly scaled on the X axis so that the
     colorbar corresponds to the actual intensity of the stems; the given
     colormarp is used on the colorbar for indexed images; and the stems no
-    longer display the markers at their top.
+    longer display the markers at their top. The Y axis is also adjusted in case
+    of peaks with high values that prevent a good overview of the histogram.
 
  ** The `fftconv2' usage "fftconv2 (v1, v2, a)", for convolution of a matrix by
     one vector in the column direction and another vector in the row direction,
--- a/main/image/inst/imhist.m	Thu Nov 22 23:13:14 2012 +0000
+++ b/main/image/inst/imhist.m	Fri Nov 23 00:09:27 2012 +0000
@@ -29,6 +29,10 @@
 ## @var{x} is a range for the bins so that @code{stem (@var{x}, @var{counts})} will
 ## show the histogram.
 ##
+## @emph{Note:} specially high peaks that may prevent an overview of the histogram
+## may not be displayed.  To avoid this, use @code{axis "auto y"} after the call
+## to @code{imhist}.
+##
 ## @seealso{hist, histc, histeq}
 ## @end deftypefn
 
@@ -139,6 +143,16 @@
   else
     stem (bins, nn, "marker", "none");
     xlim ([bins(1) bins(end)]);
+    ## we remove the box to see values with a value fo 255 (we can't remove the
+    ## line on the right since that wil remove the numbers and tics at the same
+    ## time)
+    box off;
+    ## if values are above this, they are likely outliers and prevent the
+    ## overview of the histogram
+    ylimit = median (nn) * 10;
+    if (ylim()(2) > ylimit)
+      ylim ([0 round(ylimit)]);
+    endif
     if (indexed)
       colormap (b);
     else