1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <title>Description of hist_update</title> |
---|
6 | <meta name="keywords" content="hist_update"> |
---|
7 | <meta name="description" content="'hist_update': update of a current global histogram by inclusion of a new field"> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
10 | <meta name="robots" content="index, follow"> |
---|
11 | <link type="text/css" rel="stylesheet" href="../m2html.css"> |
---|
12 | </head> |
---|
13 | <body> |
---|
14 | <a name="_top"></a> |
---|
15 | <div><a href="../index.html">Home</a> > <a href="index.html">.</a> > hist_update.m</div> |
---|
16 | |
---|
17 | <!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td> |
---|
18 | <td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>--> |
---|
19 | |
---|
20 | <h1>hist_update |
---|
21 | </h1> |
---|
22 | |
---|
23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
24 | <div class="box"><strong>'hist_update': update of a current global histogram by inclusion of a new field</strong></div> |
---|
25 | |
---|
26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
27 | <div class="box"><strong>function [val,HIST]=hist_update(val,HIST,C,dC) </strong></div> |
---|
28 | |
---|
29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
30 | <div class="fragment"><pre class="comment">'hist_update': update of a current global histogram by inclusion of a new field |
---|
31 | ------------------------------------------------------------------------ |
---|
32 | [val,HIST]=hist_update(val,HIST,C,dC) |
---|
33 | |
---|
34 | OUTPUT: |
---|
35 | val: vector of field values at which the histogram is determined (middle of bins) |
---|
36 | HIST(:,icolor): nbre of occurence of the field value in the bins whose middle is given by val |
---|
37 | can be a column vector, same size as val, or a matrix with three columns, for color images |
---|
38 | |
---|
39 | INPUT: |
---|
40 | val: existing field values from the current histogram, =[] if there is no current histogram |
---|
41 | HIST(:,icolor): current histogram, =[] if there is none |
---|
42 | can be a column vector (icolor=1), same size as val, or a matrix with three columns, for color images |
---|
43 | C(:,icolor): vector representing the current field values |
---|
44 | can be a column vector (icolor=1), or a matrix with three columns, for color images |
---|
45 | dC: width of the new bins extending val to account for the new field.</pre></div> |
---|
46 | |
---|
47 | <!-- crossreference --> |
---|
48 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
49 | This function calls: |
---|
50 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
51 | </ul> |
---|
52 | This function is called by: |
---|
53 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
54 | </ul> |
---|
55 | <!-- crossreference --> |
---|
56 | |
---|
57 | |
---|
58 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
59 | <div class="fragment"><pre>0001 <span class="comment">%'hist_update': update of a current global histogram by inclusion of a new field</span> |
---|
60 | 0002 <span class="comment">%------------------------------------------------------------------------</span> |
---|
61 | 0003 <span class="comment">%[val,HIST]=hist_update(val,HIST,C,dC)</span> |
---|
62 | 0004 <span class="comment">%</span> |
---|
63 | 0005 <span class="comment">% OUTPUT:</span> |
---|
64 | 0006 <span class="comment">% val: vector of field values at which the histogram is determined (middle of bins)</span> |
---|
65 | 0007 <span class="comment">% HIST(:,icolor): nbre of occurence of the field value in the bins whose middle is given by val</span> |
---|
66 | 0008 <span class="comment">% can be a column vector, same size as val, or a matrix with three columns, for color images</span> |
---|
67 | 0009 <span class="comment">%</span> |
---|
68 | 0010 <span class="comment">% INPUT:</span> |
---|
69 | 0011 <span class="comment">% val: existing field values from the current histogram, =[] if there is no current histogram</span> |
---|
70 | 0012 <span class="comment">% HIST(:,icolor): current histogram, =[] if there is none</span> |
---|
71 | 0013 <span class="comment">% can be a column vector (icolor=1), same size as val, or a matrix with three columns, for color images</span> |
---|
72 | 0014 <span class="comment">% C(:,icolor): vector representing the current field values</span> |
---|
73 | 0015 <span class="comment">% can be a column vector (icolor=1), or a matrix with three columns, for color images</span> |
---|
74 | 0016 <span class="comment">% dC: width of the new bins extending val to account for the new field.</span> |
---|
75 | 0017 |
---|
76 | 0018 <a name="_sub0" href="#_subfunctions" class="code">function [val,HIST]=hist_update(val,HIST,C,dC)</a> |
---|
77 | 0019 |
---|
78 | 0020 valplus=[];valminus=[]; |
---|
79 | 0021 HISTplus=[];HISTminus=[]; |
---|
80 | 0022 <span class="keyword">if</span> isempty(HIST) |
---|
81 | 0023 HIST=0; |
---|
82 | 0024 <span class="keyword">end</span> |
---|
83 | 0025 siz=size(C);nbfields=siz(2); |
---|
84 | 0026 C=double(C); |
---|
85 | 0027 valmin=min(val); |
---|
86 | 0028 valmax=max(val); |
---|
87 | 0029 Cmin=min(min(C)); Cmax=max(max(C)); |
---|
88 | 0030 <span class="keyword">if</span> isempty(val)<span class="comment">%no current histogram</span> |
---|
89 | 0031 val=[Cmin-dC/2:dC:Cmax+dC/2]; |
---|
90 | 0032 <span class="keyword">else</span> <span class="comment">%extending the current histogram beyond its maximum value</span> |
---|
91 | 0033 <span class="keyword">if</span> Cmax>=valmax+dC/2; |
---|
92 | 0034 valplus=[valmax+dC:dC:Cmax+dC/2];<span class="comment">% we extend the values val</span> |
---|
93 | 0035 HISTplus=zeros(length(valplus),nbfields);<span class="comment">% we put histogram to zero at these values</span> |
---|
94 | 0036 <span class="keyword">end</span> |
---|
95 | 0037 <span class="comment">%extending the current histogram below its minimum value</span> |
---|
96 | 0038 <span class="keyword">if</span> Cmin<=valmin-dC/2; |
---|
97 | 0039 valminus=[valmin-dC:-dC:Cmin-dC/2];<span class="comment">% we extend the values val</span> |
---|
98 | 0040 valminus=sort(valminus);<span class="comment">% we reverse the order</span> |
---|
99 | 0041 HISTminus=zeros(length(valminus),nbfields);<span class="comment">% we put histogram to zero at these values</span> |
---|
100 | 0042 <span class="keyword">end</span> |
---|
101 | 0043 val=[valminus val valplus]; |
---|
102 | 0044 <span class="keyword">end</span> |
---|
103 | 0045 HIST=[HISTminus;HIST;HISTplus]; |
---|
104 | 0046 <span class="keyword">if</span> nbfields==1 |
---|
105 | 0047 histC=(hist(C,val))';<span class="comment">% initiate the global histogram</span> |
---|
106 | 0048 <span class="keyword">elseif</span> nbfields==3 |
---|
107 | 0049 HIST1=(hist(C(:,1),val))'; |
---|
108 | 0050 HIST2=(hist(C(:,2),val))'; |
---|
109 | 0051 HIST3=(hist(C(:,3),val))'; |
---|
110 | 0052 histC=[HIST1 HIST2 HIST3]; |
---|
111 | 0053 <span class="keyword">end</span> |
---|
112 | 0054 HIST=HIST+histC;</pre></div> |
---|
113 | <hr><address>Generated on Fri 13-Nov-2009 11:17:03 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
114 | </body> |
---|
115 | </html> |
---|