source: misclib/addicon.m @ 80

Last change on this file since 80 was 80, checked in by tjniskan, 10 years ago
  • Changed the historical "an2_" prefix to "aedes_" in all files. NOTE:

Any script or function relying to Aedes functions will be broken
because of this. Just do a search/replace from "an2_" to "aedes_" in
your files and all should be well...

  • Changed the name of an2_readtab.m to a more informative

aedes_readphasetable.m

File size: 1.6 KB
Line 
1function imdata=addicon(filename,fieldname)
2% ADDICON
3%
4% Synopsis:
5%
6% Description:
7%
8% Examples:
9%
10% See also:
11%       
12
13% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
14%
15% Department of Physics, Department of Neurobiology
16% University of Kuopio, FINLAND
17%
18% This program may be used under the terms of the GNU General Public
19% License version 2.0 as published by the Free Software Foundation
20% and appearing in the file LICENSE.TXT included in the packaging of
21% this program.
22%
23% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25
26if ~iscell(filename) && ~iscell(fieldname)
27  filename = {filename};
28  fieldname={fieldname};
29end
30
31% Load icon cdata
32S=load('aedes_cdata.mat');
33cdata = S.cdata;
34 
35for ii=1:length(filename) 
36  % Read image
37  imdata = imread(filename{ii});
38  if length(size(imdata))<3
39    continue
40  end
41  imdata=[];
42  imdata = imread(filename{ii},'Backgroundcolor',[236 233 216]./255);
43 
44  % Scale image data and convert to double
45  imdata = double(imdata);
46  sz=size(imdata);
47 
48  % Add NaN:s
49  for jj=1:sz(1)
50    for kk=1:sz(2)
51      if all(squeeze(imdata(jj,kk,:))'==[236 233 216])
52        imdata(jj,kk,1)=NaN;
53        imdata(jj,kk,2)=NaN;
54        imdata(jj,kk,3)=NaN;
55      end
56    end
57  end
58  imdata = imdata/max(max(max(imdata)));
59  %imdata(imdata==0)=NaN;
60 
61  cdata.(fieldname{ii}) = imdata;
62end
63
64
65% Show in figure menubar
66fh=figure('menubar','none');
67fl_names = fieldnames(cdata);
68for ii=1:length(fl_names)
69  if isnumeric(cdata.(fl_names{ii}))
70    h=uipushtool('cdata',cdata.(fl_names{ii}));
71  end
72end
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008