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

Last change on this file since 198 was 40, checked in by sommeria, 15 years ago

-relabel_i_j added to the svn (relabel an image series with two indices)
-Menu projection Object added to uvmat, rationalizes the call of projection objects (to improve yet)
-get_plot_handles: modified in relationwith the Menu projection object
-mouse_down: corrected in relation with previous change in field transforms
-transform_field functions added to the svn
-set_object and keyboard_callback: cleaning

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