source: trunk/src/transform_field/remove_particles.m @ 557

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

functions updated to fit with new conventions

File size: 1.2 KB
Line 
1function DataOut=remove_particles(DataIn)
2%-----------------------------------------------
3%% set GUI config: no action defined
4DataOut=[];  %default  output field
5if strcmp(DataIn,'*')
6    return
7end
8
9%parameters
10threshold=200;
11nblock_x=30;%size of image subblocks for analysis
12nblock_y=30;
13%---------------------------------------------------------
14DataOut=DataIn;%default
15
16if ~isfield(DataIn,'A')
17    DataOut.Txt='remove_particels only valid for input images';
18    return
19end
20
21%BACKGROUND LEVEL
22Atype=class(DataIn.A);
23A=double(DataIn.A);
24Backg=zeros(size(A));
25Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima
26Amin=A.*Aflagmin;%values of A at local minima
27% local background: find all the local minima in image subblocks
28sumblock= inline('sum(sum(x(:)))');
29Backg=blkproc(Amin,[nblock_y nblock_x],sumblock);% take the sum in  blocks
30Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks
31Backg=Backg./Bmin; % find the average of minima in blocks
32B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image
33ImPart=(A-B);
34ImPart=ImPart.*(ImPart>threshold);
35DataOut.A=A-ImPart;%
36DataOut.A=feval(Atype,DataOut.A);
37
Note: See TracBrowser for help on using the repository browser.