Rev | 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 | %------------------------------------------------------------------------
|
---|
| 11 | function DataOut=ima_filter(DataIn)
|
---|
| 12 | np=20 %size of the filtering window
|
---|
| 13 | %definition of the cos shape matrix filter
|
---|
| 14 | ix=[1/2-np/2:-1/2+np/2];%
|
---|
| 15 | del=np/3;
|
---|
| 16 | %fct=exp(-(ix/del).^2);
|
---|
| 17 | fct2=cos(ix/((np-1)/2)*pi/2);
|
---|
| 18 | %Mfiltre=(ones(5,5)/5^2);
|
---|
| 19 | Mfiltre=fct2'*fct2;
|
---|
| 20 | Mfiltre=Mfiltre/(sum(sum(Mfiltre)));%normalize filter
|
---|
| 21 |
|
---|
| 22 | DataOut=DataIn; %default
|
---|
| 23 | Atype=class(DataIn.A)% detect integer 8 or 16 bits
|
---|
| 24 | if 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
|
---|
| 27 | else
|
---|
| 28 | DataOut.A=filter2(Mfiltre,DataIn.A)
|
---|
| 29 | DataOut.A=feval(Atype,DataOut.A);%transform to the initial image format
|
---|
| 30 | end
|
---|
| 31 | |
---|
Note: See
TracBrowser
for help on using the repository browser.