X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=octave_packages%2Fimage-1.0.15%2Fhisteq.m;fp=octave_packages%2Fimage-1.0.15%2Fhisteq.m;h=e6d7e1b57a6fd4226fc85f6d7bb714e025caac57;hb=f5f7a74bd8a4900f0b797da6783be80e11a68d86;hp=0000000000000000000000000000000000000000;hpb=1705066eceaaea976f010f669ce8e972f3734b05;p=CreaPhase.git
diff --git a/octave_packages/image-1.0.15/histeq.m b/octave_packages/image-1.0.15/histeq.m
new file mode 100644
index 0000000..e6d7e1b
--- /dev/null
+++ b/octave_packages/image-1.0.15/histeq.m
@@ -0,0 +1,47 @@
+## Copyright (C) 2000 Kai Habel
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; If not, see .
+
+## -*- texinfo -*-
+## @deftypefn {Function File} @var{J} = histeq (@var{I}, @var{n})
+## Histogram equalization of a gray-scale image. The histogram contains
+## @var{n} bins, which defaults to 64.
+##
+## @var{I}: Image in double format, with values from 0.0 to 1.0
+##
+## @var{J}: Returned image, in double format as well
+## @seealso{imhist}
+## @end deftypefn
+
+## Author: Kai Habel
+## Date: 08. August 2000
+## Modified-by: Jonas Wagner
+## Date: 11. February 2008
+
+function J = histeq (I, n)
+ if (nargin == 0)
+ print_usage();
+ elseif (nargin == 1)
+ n = 64;
+ endif
+
+ [r,c] = size(I);
+ I = mat2gray(I);
+ [X,map] = gray2ind(I, n);
+ [nn,xx] = imhist(I, n);
+ Icdf = 1 / prod(size(I)) * cumsum(nn);
+ J = reshape(Icdf(X),r,c);
+ plot(Icdf,'b');
+ legend( 'Image Cumulative Density Function');
+endfunction