cemif.m
上传用户:sundar2007
上传日期:2020-06-25
资源大小:48k
文件大小:2k
- function [fusion] = cemif(im1,im2,op,r,consistency)
- %
- %cemif.m, v 1.1 2002/02/06 18:01:40
- %===========================================================================
- % Eduardo Fernandez Canga - University of Bath
- %
- % Copyright (c) 2001
- %===========================================================================
- %
- % [fusion] = cemif(im1,im2,op,r,consistency)
- %
- % im1: input image
- % im2: input image
- % op: selection of background fussion method
- % 1 - first image background (default)
- % 2 - second image background
- % 3 - both backgrounds
- % r: averaging mask size (default 11)
- % consistency: apply consistency
- % 1=yes (default)
- % 0=no
- %
- %===========================================================================
- if nargin < 5, consistency=1;end
- if nargin < 4, r=11;end
- if nargin < 3, op=1;end
- if any (size(im1)~=size(im2))
- error('Error: Different Size Images')
- end
- %Calculating backgrounds
- back1=imaver(im1,r);
- back2=imaver(im2,r);
- %Calculating foregrounds
- fore1=im1-back1;
- fore2=im2-back2;
- %Fusion of foregrounds
- decision=abs(fore1)>abs(fore2);
- if consistency==1 % apply consistency check if it is active
- mask=ones(3,3)/9; % use 3x3 window mask
- decision=impad(double(decision),1);
- decision=round(conv2(decision,mask,'valid'));
- end
- fore=fore1.*decision+fore2.*(~decision);
- %Fusion of backgrounds
- switch op
- case 1 % Selected backgrounds of img 1
- back=back1;
- case 2 % Selected backgrounds of img 2
- back=back2;
- case 3 % Selected both backgrounds
- m1=mean(mean(im1));
- m2=mean(mean(im2));
- back=back1+back2-(m1+m2)/2;
- otherwise
- error('Invalid input for background fussion method');
- end
- fusion=back+fore;