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

Last change on this file since 956 was 956, checked in by sommeria, 5 years ago

various

File size: 2.4 KB
Line 
1% 'ima_filter': example of image transform with input parameters: low-pass filter of an image
2
3%------------------------------------------------------------------------
4%%%%  Use the general syntax for transform fields with a single input and parameters %%%%
5% OUTPUT:
6% DataOut:   output field structure
7%
8%INPUT:
9% DataIn:  input field structure
10% Param: matlab structure whose field Param.TransformInput contains the filter parameters
11%-----------------------------------
12
13%=======================================================================
14% Copyright 2008-2016, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
15%   http://www.legi.grenoble-inp.fr
16%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
17%
18%     This file is part of the toolbox UVMAT.
19%
20%     UVMAT is free software; you can redistribute it and/or modify
21%     it under the terms of the GNU General Public License as published
22%     by the Free Software Foundation; either version 2 of the license,
23%     or (at your option) any later version.
24%
25%     UVMAT is distributed in the hope that it will be useful,
26%     but WITHOUT ANY WARRANTY; without even the implied warranty of
27%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28%     GNU General Public License (see LICENSE.txt) for more details.
29%=======================================================================
30
31function DataOut=ima_filter(DataIn)
32
33Origin_x=469;
34DataOut=DataIn; %default
35DataOut.A=
36
37%definition of the cos shape matrix filter
38ix=[1/2-Param.TransformInput.FilterBoxSize_x/2:-1/2+Param.TransformInput.FilterBoxSize_x/2];%
39iy=[1/2-Param.TransformInput.FilterBoxSize_y/2:-1/2+Param.TransformInput.FilterBoxSize_y/2];%
40%del=np/3;
41%fct=exp(-(ix/del).^2);
42fct2_x=cos(ix/((Param.TransformInput.FilterBoxSize_x-1)/2)*pi/2);
43fct2_y=cos(iy/((Param.TransformInput.FilterBoxSize_y-1)/2)*pi/2);
44%Mfiltre=(ones(5,5)/5^2);
45Mfiltre=fct2_y'*fct2_x;
46Mfiltre=Mfiltre/(sum(sum(Mfiltre)));%normalize filter
47
48Atype=class(DataIn.A);% detect integer 8 or 16 bits
49if numel(size(DataIn.A))==3
50    DataOut.A=filter2(Mfiltre,sum(DataIn.A,3));%filter the input image, after summation on the color component (for color images)
51    DataOut.A=uint16(DataOut.A); %transform to 16 bit images
52else
53    DataOut.A=filter2(Mfiltre,DataIn.A)
54    DataOut.A=feval(Atype,DataOut.A);%transform to the initial image format
55end
56 
Note: See TracBrowser for help on using the repository browser.