source: trunk/src/transform_field/ima_filter.m @ 575

Last change on this file since 575 was 574, checked in by sommeria, 11 years ago

clean the transform fcts

File size: 1.1 KB
Line 
1% 'ima_filter': low-pass filtr of an image (builtin filtering parameter)
2
3%------------------------------------------------------------------------
4%%%%  Use the general syntax for transform fields with a single input %%%%
5% OUTPUT:
6% DataOut:   output field structure
7
8%INPUT:
9% DataIn:  first input field structure
10%------------------------------------------------------------------------
11function DataOut=ima_filter(DataIn)
12np=20 %size of the filtering window
13%definition of the cos shape matrix filter
14ix=[1/2-np/2:-1/2+np/2];%
15del=np/3;
16%fct=exp(-(ix/del).^2);
17fct2=cos(ix/((np-1)/2)*pi/2);
18%Mfiltre=(ones(5,5)/5^2);
19Mfiltre=fct2'*fct2;
20Mfiltre=Mfiltre/(sum(sum(Mfiltre)));%normalize filter
21
22DataOut=DataIn; %default
23Atype=class(DataIn.A)% detect integer 8 or 16 bits
24if numel(size(DataIn.A))==3
25    DataOut.A=filter2(Mfiltre,sum(DataIn.A,3));%filter the input image, after summation on the color component (for color images)
26    DataOut.A=uint16(DataOut.A); %transform to 16 bit images
27else
28    DataOut.A=filter2(Mfiltre,DataIn.A)
29    DataOut.A=feval(Atype,DataOut.A);%transform to the initial image format
30end
31 
Note: See TracBrowser for help on using the repository browser.