-
Notifications
You must be signed in to change notification settings - Fork 1
/
superImp.m
67 lines (64 loc) · 2.97 KB
/
superImp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (c) 2012, William E. Allen ([email protected])
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without modification,
% are permitted provided that the following conditions are met:
%
% - Redistributions of source code must retain the above copyright notice,
% this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright notice,
% this list of conditions and the following disclaimer in the documentation
% and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
% DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
% LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
% ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
% EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function im = superImp(c,frames,rad,maxVal,bb)
%%SUPERIMP combines multiple components into 1 image, assigning each
%%component a different color, for each pixel, choosing the component with
%%the largest magnitude at that location. All components are normalized.
%%INPUTS: c = all 2-d image components
%% frames = which components to combine in image (choose ones with well-defined features)
%% rad = width of gaussian smoothing kernel
%% maxVal = if you want to normalize all components by a fixed value (default: normalize maximum of each component to 1)
%% bb = in case you want a separate background image to assign the intensity of the pixel, rather than the componnent
x = c(frames,:,:);
for i = 1:size(x,1)
if rad
x(i,:,:) = imfilter(squeeze(x(i,:,:)),fspecial('gaussian',5,rad));
end
if exist('maxVal','var')
x(i,:,:) = x(i,:,:)/max(max(max(x(i,:,:))));
else
x(i,:,:) = x(i,:,:)/maxVal;
end
end
x = min(1,max(0,x));
[a b]= max(x);
a = squeeze(a); b = squeeze(b);
im = zeros(3,size(a,1),size(a,2));
for i = 1:size(x,1);
im(1,b == i) = i/size(x,1);
im(2,b == i) = 1;
im(3,b == i) = a(b == i);
if exist('bb','var')
bb = squeeze(mean(bb));
bb = bb-150;
bb = bb./1500;bb = max(0,min(bb,1));%max(max(bb));
im(3,b == i) = bb(b == i);
end
end
im = max(0,im);
im = permute(im,[2 3 1]);
im = hsv2rgb(im);
figure;image(im);