Home > functions > common > morphology > vb_mri_histgram.m

vb_mri_histgram

PURPOSE ^

calculate MRI image histogram

SYNOPSIS ^

function [Nhist, level, step] = vb_mri_histgram(B, Nmax, NMAX)

DESCRIPTION ^

 calculate MRI image histogram
  [Nhist, level, step]    = vb_mri_histgram(B)
  [Nhist, level, step] = vb_mri_histgram(B, Nmax, NMAX)
   B   : Image intensity
 Nhist ; Histogram
 level : level of histogram
 step  : step size of level (integer)
 if max(B) <= NMAX, step = 1
 else,              step = round( max(B)/Nmax );

 Masa-aki Sato 2010-10-18

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    [Nhist, level, step] = vb_mri_histgram(B, Nmax, NMAX)
0002 % calculate MRI image histogram
0003 %  [Nhist, level, step]    = vb_mri_histgram(B)
0004 %  [Nhist, level, step] = vb_mri_histgram(B, Nmax, NMAX)
0005 %   B   : Image intensity
0006 % Nhist ; Histogram
0007 % level : level of histogram
0008 % step  : step size of level (integer)
0009 % if max(B) <= NMAX, step = 1
0010 % else,              step = round( max(B)/Nmax );
0011 %
0012 % Masa-aki Sato 2010-10-18
0013 %
0014 % Copyright (C) 2011, ATR All Rights Reserved.
0015 % License : New BSD License(see VBMEG_LICENSE.txt)
0016 
0017 % Histogram level
0018 if nargin < 2, Nmax = 256; end;
0019 if nargin < 3, NMAX = Nmax; end;
0020 
0021 % Max of MRI image
0022 Bmax = fix(max(B(:)));
0023 
0024 % Adjust histogram level according to Bmax
0025 if Bmax <= NMAX,
0026     step = 1;
0027 else
0028     step = round(Bmax/Nmax);
0029 end
0030 
0031 Nlevel    = 0:step:Bmax;
0032 
0033 [Nhist, level]    = hist(B(:),Nlevel);
0034 
0035 level = level + step;
0036 
0037 return
0038 
0039 if nargin < 2, Nmax = 1024; end;
0040 if nargin < 3, NMAX = 2048; end;
0041 
0042 % Max of MRI image
0043 Bmax = fix(max(B(:)));
0044 
0045 % Adjust histogram level according to Bmax
0046 if Bmax < NMAX, Nmax = Bmax; end;
0047 
0048 % histogram for MRI image intensity
0049 step = 1;
0050 Nlevel    = (0:step:Nmax)*(Bmax/Nmax);
0051 
0052 [Nhist, level]    = hist(B(:),Nlevel);
0053 
0054 level = level + step*(Bmax/Nmax);

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005