Index: trunk/src/transform_field/FFT2_detrend.m
===================================================================
--- trunk/src/transform_field/FFT2_detrend.m	(revision 567)
+++ trunk/src/transform_field/FFT2_detrend.m	(revision 574)
@@ -1,14 +1,14 @@
-% 'FFT': calculate and display 2D spectrum of the input scalar
-%  GUI_input=FFT(hget_field)
-%
+% 'FFT2_detrend': calculate the 2D spectrum of the input scalar after removing the linear trend
+
+%------------------------------------------------------------------------
+%%%%  Use the general syntax for transform fields with a single input %%%%
 % OUTPUT: 
-% GUI_input: option for display in the GUI get_field
-%
+% DataOut:   output field structure 
+
 %INPUT:
-% hget_field: handles of the GUI get_field
-%
-
+% DataIn:  first input field structure
+%------------------------------------------------------------------------
 function DataOut=FFT2_detrend(DataIn)
-%% set GUI config
+%------------------------------------------------------------------------
 DataOut=[];
 if strcmp(DataIn,'*')   
Index: trunk/src/transform_field/im_filter.m
===================================================================
--- trunk/src/transform_field/im_filter.m	(revision 567)
+++ 	(revision )
@@ -1,21 +1,0 @@
-function DataOut=im_filter(DataIn,Calib)
-np=20 %size ofthe filtering window
-%definition of the cos shape matrix filter
-ix=[1/2-np/2:-1/2+np/2];%
-del=np/3;
-%fct=exp(-(ix/del).^2);
-fct2=cos(ix/((np-1)/2)*pi/2);
-%Mfiltre=(ones(5,5)/5^2);
-Mfiltre=fct2'*fct2;
-Mfiltre=Mfiltre/(sum(sum(Mfiltre)));%normalize filter
-
-DataOut=DataIn; %default
-Atype=class(DataIn.A)% detect integer 8 or 16 bits
-if numel(size(DataIn.A))==3
-    DataOut.A=filter2(Mfiltre,sum(DataIn.A,3));%filter the input image, after summation on the color component (for color images)
-    DataOut.A=uint16(DataOut.A); %transform to 16 bit images
-else
-    DataOut.A=filter2(Mfiltre,DataIn.A)
-    DataOut.A=feval(Atype,DataOut.A);%transform to the initial image format
-end
- 
Index: trunk/src/transform_field/im_levels.m
===================================================================
--- trunk/src/transform_field/im_levels.m	(revision 567)
+++ 	(revision )
@@ -1,52 +1,0 @@
-function DataOut=im_levels(DataIn)
-%% set GUI config: no action defined
-DataOut=[];  %default  output field
-if strcmp(DataIn,'*')
-    return
-end
-%-----------------------------------------------
-%parameters
-np=30
-%--------------------------------------------------------- 
-DataOut=DataIn;%default
-
-B=double(DataIn.A(:,:,1));
-windowsize=round(min(size(B,1),size(B,2))/20);
-windowsize=floor(windowsize/2)*2+1;
-ix=[1/2-windowsize/2:-1/2+windowsize/2];%
-%del=np/3;
-%fct=exp(-(ix/del).^2);
-fct2=cos(ix/((np-1)/2)*pi/2);
-%Mfiltre=(ones(5,5)/5^2);
-%Mfiltre=fct2';
-Mfiltre=fct2'*fct2;
-Mfiltre=Mfiltre/(sum(sum(Mfiltre)));
-
-C=filter2(Mfiltre,B);
-C(:,1:windowsize)=C(:,windowsize)*ones(1,windowsize);
-C(:,end-windowsize+1:end)=C(:,end-windowsize+1)*ones(1,windowsize);
-C(1:windowsize,:)=ones(windowsize,1)*C(windowsize,:);
-C(end-windowsize+1:end,:)=ones(windowsize,1)*C(end-windowsize,:);
-C=tanh(B./(2*C));
-[n,c]=hist(reshape(C,1,[]),100);
-% figure;plot(c,n);
-
-[m,i]=max(n);
-c_max=c(i);
-[dummy,index]=sort(abs(c-c(i)));
-n=n(index);
-c=c(index);
-i_select = find(cumsum(n)<0.95*sum(n));
-if isempty(i_select)
-    i_select = 1:length(c);
-end
-c_select=c(i_select);
-n_select=n(i_select);
-cmin=min(c_select);
-cmax=max(c_select);
-C=(C-cmin)/(cmax-cmin)*256;
-DataOut.AA=uint8(C);
-
-
-
-DataOut.A=uint8(C);
Index: trunk/src/transform_field/ima_filter.m
===================================================================
--- trunk/src/transform_field/ima_filter.m	(revision 574)
+++ trunk/src/transform_field/ima_filter.m	(revision 574)
@@ -0,0 +1,31 @@
+% 'ima_filter': low-pass filtr of an image (builtin filtering parameter)
+
+%------------------------------------------------------------------------
+%%%%  Use the general syntax for transform fields with a single input %%%%
+% OUTPUT: 
+% DataOut:   output field structure 
+
+%INPUT:
+% DataIn:  first input field structure
+%------------------------------------------------------------------------
+function DataOut=ima_filter(DataIn)
+np=20 %size of the filtering window
+%definition of the cos shape matrix filter
+ix=[1/2-np/2:-1/2+np/2];%
+del=np/3;
+%fct=exp(-(ix/del).^2);
+fct2=cos(ix/((np-1)/2)*pi/2);
+%Mfiltre=(ones(5,5)/5^2);
+Mfiltre=fct2'*fct2;
+Mfiltre=Mfiltre/(sum(sum(Mfiltre)));%normalize filter
+
+DataOut=DataIn; %default
+Atype=class(DataIn.A)% detect integer 8 or 16 bits
+if numel(size(DataIn.A))==3
+    DataOut.A=filter2(Mfiltre,sum(DataIn.A,3));%filter the input image, after summation on the color component (for color images)
+    DataOut.A=uint16(DataOut.A); %transform to 16 bit images
+else
+    DataOut.A=filter2(Mfiltre,DataIn.A)
+    DataOut.A=feval(Atype,DataOut.A);%transform to the initial image format
+end
+ 
Index: trunk/src/transform_field/ima_levels.m
===================================================================
--- trunk/src/transform_field/ima_levels.m	(revision 574)
+++ trunk/src/transform_field/ima_levels.m	(revision 574)
@@ -0,0 +1,52 @@
+function DataOut=im_levels(DataIn)
+%% set GUI config: no action defined
+DataOut=[];  %default  output field
+if strcmp(DataIn,'*')
+    return
+end
+%-----------------------------------------------
+%parameters
+np=30
+%--------------------------------------------------------- 
+DataOut=DataIn;%default
+
+B=double(DataIn.A(:,:,1));
+windowsize=round(min(size(B,1),size(B,2))/20);
+windowsize=floor(windowsize/2)*2+1;
+ix=[1/2-windowsize/2:-1/2+windowsize/2];%
+%del=np/3;
+%fct=exp(-(ix/del).^2);
+fct2=cos(ix/((np-1)/2)*pi/2);
+%Mfiltre=(ones(5,5)/5^2);
+%Mfiltre=fct2';
+Mfiltre=fct2'*fct2;
+Mfiltre=Mfiltre/(sum(sum(Mfiltre)));
+
+C=filter2(Mfiltre,B);
+C(:,1:windowsize)=C(:,windowsize)*ones(1,windowsize);
+C(:,end-windowsize+1:end)=C(:,end-windowsize+1)*ones(1,windowsize);
+C(1:windowsize,:)=ones(windowsize,1)*C(windowsize,:);
+C(end-windowsize+1:end,:)=ones(windowsize,1)*C(end-windowsize,:);
+C=tanh(B./(2*C));
+[n,c]=hist(reshape(C,1,[]),100);
+% figure;plot(c,n);
+
+[m,i]=max(n);
+c_max=c(i);
+[dummy,index]=sort(abs(c-c(i)));
+n=n(index);
+c=c(index);
+i_select = find(cumsum(n)<0.95*sum(n));
+if isempty(i_select)
+    i_select = 1:length(c);
+end
+c_select=c(i_select);
+n_select=n(i_select);
+cmin=min(c_select);
+cmax=max(c_select);
+C=(C-cmin)/(cmax-cmin)*256;
+DataOut.AA=uint8(C);
+
+
+
+DataOut.A=uint8(C);
Index: trunk/src/transform_field/ima_remove_background.m
===================================================================
--- trunk/src/transform_field/ima_remove_background.m	(revision 574)
+++ trunk/src/transform_field/ima_remove_background.m	(revision 574)
@@ -0,0 +1,40 @@
+% 'ima_remove_background': removes backgound from an image (using the local minimum)
+% requires the Matlab image processing toolbox
+
+%------------------------------------------------------------------------
+%%%%  Use the general syntax for transform fields with a single input %%%%
+% OUTPUT: 
+% DataOut:   output field structure 
+
+%INPUT:
+% DataIn:  first input field structure
+%------------------------------------------------------------------------
+function DataOut=remove_background(DataIn)
+%------------------------------------------------------------------------
+DataOut=[];  %default  output field
+if strcmp(DataIn,'*')
+    return
+end
+
+%parameters
+threshold=200
+nblock_x=30;%size of image subblocks for analysis
+nblock_y=30;
+%---------------------------------------------------------
+DataOut=DataIn;%default
+
+%BACKGROUND LEVEL
+Atype=class(DataIn.A);
+A=double(DataIn.A);
+Backg=zeros(size(A));
+Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
+Amin=A.*Aflagmin;%values of A at local minima
+% local background: find all the local minima in image subblocks
+sumblock= inline('sum(sum(x(:)))');
+Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in  blocks
+Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
+Backg=Backg./Bmin; % find the average of minima in blocks
+B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
+ImPart=(A-B);
+DataOut.A=ImPart.*(ImPart>threshold);
+DataOut.A=feval(Atype,DataOut.A);
Index: trunk/src/transform_field/ima_remove_particles.m
===================================================================
--- trunk/src/transform_field/ima_remove_particles.m	(revision 574)
+++ trunk/src/transform_field/ima_remove_particles.m	(revision 574)
@@ -0,0 +1,47 @@
+% 'ima_remove_particles': removes particles from an image (keeping the local minimum)
+% requires the Matlab image processing toolbox
+
+%------------------------------------------------------------------------
+%%%%  Use the general syntax for transform fields with a single input %%%%
+% OUTPUT: 
+% DataOut:   output field structure 
+
+%INPUT:
+% DataIn:  first input field structure
+%------------------------------------------------------------------------
+function DataOut=ima_remove_particles(DataIn)
+%------------------------------------------------------------------------
+DataOut=[];  %default  output field
+if strcmp(DataIn,'*')
+    return
+end
+
+%parameters
+threshold=200;
+nblock_x=30;%size of image subblocks for analysis
+nblock_y=30;
+%--------------------------------------------------------- 
+DataOut=DataIn;%default
+
+if ~isfield(DataIn,'A')
+    DataOut.Txt='remove_particles only valid for input images';
+    return
+end
+
+%BACKGROUND LEVEL
+Atype=class(DataIn.A);
+A=double(DataIn.A);
+Backg=zeros(size(A));
+Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
+Amin=A.*Aflagmin;%values of A at local minima
+% local background: find all the local minima in image subblocks
+sumblock= inline('sum(sum(x(:)))');
+Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in  blocks
+Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
+Backg=Backg./Bmin; % find the average of minima in blocks
+B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
+ImPart=(A-B);
+ImPart=ImPart.*(ImPart>threshold);
+DataOut.A=A-ImPart;%
+DataOut.A=feval(Atype,DataOut.A);
+
Index: trunk/src/transform_field/phys.m
===================================================================
--- trunk/src/transform_field/phys.m	(revision 567)
+++ trunk/src/transform_field/phys.m	(revision 574)
@@ -1,20 +1,20 @@
-%'phys': transforms image (px) to real world (phys) coordinates using geometric calibration parameters
-% DataOut=phys(Data,CalibData) , transform one input field
-% [DataOut,DataOut_1]=phys(Data,CalibData,Data_1,CalibData_1), transform two input fields
-
+%'phys': transforms image (Unit='pixel') to real world (phys) coordinates using geometric calibration parameters.  It acts if the input field contains the tag 'CoordTUnit' with value 'pixel'
+
+%------------------------------------------------------------------------
+%%%%  Use the general syntax for transform fields %%%%
 % OUTPUT: 
-% DataOut:   structure representing the first field in phys coordinates
-% DataOut_1: structure representing the second  field in phys coordinates
+% DataOut:   output field structure 
 
 %INPUT:
-% Data:  structure of input data 
-%       with fields .A (image or scalar matrix), AX, AY
-%       .X,.Y,.U,.V, .DjUi
-%       .ZIndex: index of plane in multilevel case 
-%       .CoordType='phys' or 'px', The function ACTS ONLY IF .CoordType='px'
-% CalibData: structure containing calibration parameters or a subtree Calib.GeometryCalib =calibration data (tsai parameters)
-% Data_1, CalibData_1: same as Data, CalibData for the second field.
-
+% DataIn:  first input field structure
+% XmlData: first input parameter structure,
+%        .GeometryCalib: substructure of the calibration parameters 
+% DataIn_1: optional second input field structure
+% XmlData_1: optional second input parameter structure
+%         .GeometryCalib: substructure of the calibration parameters 
+%------------------------------------------------------------------------
 function DataOut=phys(DataIn,XmlData,DataIn_1,XmlData_1)
+%------------------------------------------------------------------------
+
 % A FAIRE: 1- verifier si DataIn est une 'field structure'(.ListVarName'):
 % chercher ListVarAttribute, for each field (cell of variables):
@@ -25,5 +25,5 @@
 %            'D_i' if '.Role='vector_x,...',
 %              'scalar', else (thenno change except scale factor)
-%% set GUI config if DataIn='*'
+
 DataOut=[];
 DataOut_1=[]; %default second  output field
Index: trunk/src/transform_field/phys_polar.m
===================================================================
--- trunk/src/transform_field/phys_polar.m	(revision 567)
+++ trunk/src/transform_field/phys_polar.m	(revision 574)
@@ -1,2 +1,17 @@
+%'phys_polar': transforms image (Unit='pixel') to polar (phys) coordinates using geometric calibration parameters
+
+%------------------------------------------------------------------------
+%%%%  Use the general syntax for transform fields %%%%
+% OUTPUT: 
+% DataOut:   output field structure 
+%      .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components
+
+%INPUT:
+% DataIn:  first input field structure
+% XmlData: first input parameter structure,
+%        .GeometryCalib: substructure of the calibration parameters 
+% DataIn_1: optional second input field structure
+% XmlData_1: optional second input parameter structure
+%         .GeometryCalib: substructure of the calibration parameters 
 % transform image coordinates (px) to polar physical coordinates 
 %[DataOut,DataOut_1]=phys_polar(varargin)
@@ -11,6 +26,7 @@
 % Data_1:  second input field (not mandatory)
 % CalibData_1= calibration parameters for the second field
-
-function [DataOut,DataOut_1]=phys_polar(varargin)
+%------------------------------------------------------------------------
+function DataOut=phys_polar(DataIn,XmlData,DataIn_1,XmlData_1)
+%------------------------------------------------------------------------
 Calib{1}=[];
 if nargin==2||nargin==4
Index: trunk/src/transform_field/px.m
===================================================================
--- trunk/src/transform_field/px.m	(revision 567)
+++ 	(revision )
@@ -1,143 +1,0 @@
-%'px': transform fields from physical coordinates (phys) to image (px) coordinates 
-
-% OUTPUT: 
-% DataOut:   structure of modified data (transforms DataIn)
-%       DataOut.CoordType='px': labels image coordinates
-%       DataOut.CoordUnit= 'px' : units of output coordinates
-%       DataOut.X and .Y arrays of image coordinates X, Y
-%       DataOut.U, .V velocity in pixel displacement on the image (unit=px), if velocity exists as input 
-%    
-%INPUT:
-% DataIn:  structure of possible input data (like UvData) or cell of structures (several fields):
-%      DataIn.CoordType='phys': allows transform to px, else no transform   (DataOut=DataIn)
-%      DataIn.X and .Y arrays of physical coordinates X, Y
-%      DataIn.Z corresponding array of Z coordinates (=0 by default)
-%      DataIn.U, V corresponding array of velocity components
-%      DataIn.W corresponding array of the third velocity component in 3D case
-%      DataIn.dt: time interval of the image pair used for velocity measurement (NEEDED TO GET OUTPUT RESULT))
-%      DataIn.A, AX, AY : image or scalar input -> EMPTY  CORRESPONDING OUTPUT (A REVOIR)
-%      Other fields in DataIn: copied to DataOut without modification
-% Calib: structure containing the  substructure Calib.GeometryCalib with the calibration parameters
-%
-% call the function  px_XYZ (case of images) for pointwise coordinate transforms
-
-function [DataOut,DataOut_1]=px(Data,CalibData,Data_1,CalibData_1)%DataIn,Calib)
-% A FAIRE: 1- verifier si DataIn est une 'field structure'(.ListVarName'):
-% chercher ListVarAttribute, for each field (cell of variables):
-%   .CoordType: 'phys' or 'px'   (default==px, no transform)
-%   .scale_factor: =dt (to transform displacement into velocity) default=1
-%   .covariance: 'scalar', 'coord', 'D_i': covariant (like velocity), 'D^i': contravariant (like gradient), 'D^jD_i' (like strain tensor)
-%   (default='coord' if .Role='coord_x,_y..., 
-%            'D_i' if '.Role='vector_x,...',
-%              'scalar', else (thenno change except scale factor)
-if  ~(exist('CalibData','var') && isfield(CalibData,'GeometryCalib'))
-    DataOut=Data;
-else
-    DataOut=px_1(Data,CalibData.GeometryCalib);
-end
-if isfield(DataOut,'Z')
-    DataOut=rmfield(DataOut,'Z');
-end
-if exist('Data_1','var')% if there is a second input field, it is also transformed
-    if ~(exist('CalibData_1','var') && isfield(CalibData_1,'GeometryCalib'))
-        DataOut_1=Data_1;
-    else
-        DataOut_1=px_1(Data_1,CalibData_1.GeometryCalib);
-    end
-    if isfield(DataOut_1,'Z')
-        DataOut_1=rmfield(DataOut_1,'Z');
-    end
-else % no second input field then empty second output field
-    DataOut_1=[];
-end
-
-
-%------------------------------------------------
-function DataOut=px_1(Data,Calib)
-DataOut=Data;%default
-
-%Act only if .CoordType=phys, and Calib defined
-if isfield(Data,'CoordType')&& isequal(Data.CoordType,'phys')&& ~isempty(Calib)
-    DataOut.CoordType='px'; %put flag for pixel coordinates
-    DataOut.CoordUnit='px';
-    %transform of X,Y coordinates
-    if isfield(Data,'Z')&&~isempty(Data.Z)
-        Z=Data.Z;
-    else
-        Z=0;
-    end
-    if isfield(Data,'X') & isfield(Data,'Y')
-        [DataOut.X,DataOut.Y]=px_XYZ(Calib,Data.X,Data.Y,Z);
-        if isfield(Data,'U')&isfield(Data,'V')& isfield(Data,'dt')& ~isequal(Data.dt,0)
-            Data.U=Data.U*Data.dt;
-            Data.V=Data.V*Data.dt;
-            if isfield(Data,'W')
-                W=Data.W*Data.dt;
-            else
-                W=0;
-            end
-            [XOut_1,YOut_1]=px_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z-W/2);
-            [XOut_2,YOut_2]=px_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z+W/2);
-            DataOut.U=XOut_2-XOut_1;
-            DataOut.V=YOut_2-YOut_1;
-        end
-    end
-    %transform of an image
-    if isfield(Data,'A')&isfield(Data,'AX')&~isempty(Data.AX) & isfield(Data,'AY')&...
-                                   isfield(Data,'AY')&~isempty(Data.AY)&length(Data.A)>1
-%         if isfield(Data,'Field')&isequal(Data.Field,'images')
-          %NO TRANSFORM FROM phys to px for images
-            DataOut.A=[];% 
-    end
-end
-
-%'px_XYZ': transform phys coordinates to image coordinates (px)
-%
-% OUPUT:
-% X,Y: array of coordinates in the image cooresponding to the input physical positions 
-%                    (origin at lower leftcorner, unit=pixel)
-
-% INPUT:
-% Calib: structure containing the calibration parameters (read from the ImaDoc .xml file)
-% Xphys, Yphys: array of x,y physical coordinates
-% [Zphys]: corresponding array of z physical coordinates (0 by default)
-
-% 
-% function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
-% X=[];%default
-% Y=[];
-% % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
-% %     Zindex=Z;
-% %     planepos=Calib.PlanePos{Zindex};
-% %     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
-% % else
-% %     zphys=0;
-% % end
-% if ~exist('Zphys','var')
-%     Zphys=0;
-% end
-% 
-% %%%%%%%%%%%%%
-% if isfield(Calib,'R')
-%     R=(Calib.R)';
-%     xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
-%     yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
-%     zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
-% %undistorted image coordinates
-%     Xu=Calib.f*xc./zc;
-%     Yu=Calib.f*yc./zc;
-% %distorted image coordinates
-%     distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
-% % distortion=1;
-%     Xd=Xu./distortion;
-%     Yd=Yu./distortion;
-% %pixel coordinates
-%     X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
-%     Y=Yd/Calib.dpy+Calib.Cy;
-% 
-% elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib  
-%         X=Xphys*Calib.Pxcmx;
-%         Y=Yphys*Calib.Pxcmy;
-% end
-
-
Index: trunk/src/transform_field/remove_background.m
===================================================================
--- trunk/src/transform_field/remove_background.m	(revision 567)
+++ 	(revision )
@@ -1,30 +1,0 @@
-function DataOut=remove_background(DataIn)
-%-----------------------------------------------
-%% set GUI config: no action defined
-DataOut=[];  %default  output field
-if strcmp(DataIn,'*')
-    return
-end
-
-%parameters
-threshold=200
-nblock_x=30;%size of image subblocks for analysis
-nblock_y=30;
-%---------------------------------------------------------
-DataOut=DataIn;%default
-
-%BACKGROUND LEVEL
-Atype=class(DataIn.A);
-A=double(DataIn.A);
-Backg=zeros(size(A));
-Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
-Amin=A.*Aflagmin;%values of A at local minima
-% local background: find all the local minima in image subblocks
-sumblock= inline('sum(sum(x(:)))');
-Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in  blocks
-Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
-Backg=Backg./Bmin; % find the average of minima in blocks
-B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
-ImPart=(A-B);
-DataOut.A=ImPart.*(ImPart>threshold);
-DataOut.A=feval(Atype,DataOut.A);
Index: trunk/src/transform_field/remove_particles.m
===================================================================
--- trunk/src/transform_field/remove_particles.m	(revision 567)
+++ 	(revision )
@@ -1,37 +1,0 @@
-function DataOut=remove_particles(DataIn)
-%-----------------------------------------------
-%% set GUI config: no action defined
-DataOut=[];  %default  output field
-if strcmp(DataIn,'*')
-    return
-end
-
-%parameters
-threshold=200;
-nblock_x=30;%size of image subblocks for analysis
-nblock_y=30;
-%--------------------------------------------------------- 
-DataOut=DataIn;%default
-
-if ~isfield(DataIn,'A')
-    DataOut.Txt='remove_particels only valid for input images';
-    return
-end
-
-%BACKGROUND LEVEL
-Atype=class(DataIn.A);
-A=double(DataIn.A);
-Backg=zeros(size(A));
-Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
-Amin=A.*Aflagmin;%values of A at local minima
-% local background: find all the local minima in image subblocks
-sumblock= inline('sum(sum(x(:)))');
-Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in  blocks
-Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
-Backg=Backg./Bmin; % find the average of minima in blocks
-B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
-ImPart=(A-B);
-ImPart=ImPart.*(ImPart>threshold);
-DataOut.A=A-ImPart;%
-DataOut.A=feval(Atype,DataOut.A);
-
